Nuxt

by maya tominaga

HTML

<div id="app">
  <div class="page-about">
    <section>
      <h2 class="section-title effect-fade-side">Works</h2>
      <div class="article-body works">
        <div class="article-content">
          <div class="article-image">
            <p id="trigger1">ボタン1</p>
            <button style="color: red; width: 200px; height: 100px;">
              1
            </button>
          </div>
        </div>
        <div class="article-content">
          <div class="article-image">
            <p id="trigger2">ボタン2</p>
            <button id="image1" style="color: red; width: 200px; height: 100px;">
              1
            </button>
          </div>
        </div>
        <div class="article-content">
          <div class="article-image">
            <p id="trigger3">ボタン3</p>
            <button id="image2" style="color: red; width: 200px; height: 100px;">
              1
            </button>
          </div>
        </div>
        <div class="article-content">
          <div class="article-image">
            <p>画像4</p>
            <p id="trigger4">ボタン4</p>
            <button id="image3" style="color: red; width: 200px; height: 100px;">
              1
            </button>
          </div>
        </div>
      </div>
    </section>
  </div>
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

.article-body {
  min-height: 300px;
  background-color: #fff;
  box-shadow: 1px 27px 39px 0 rgba(0, 0, 0, 0.07);

  &.works {
    padding: 50px 30px 50px 80px;
  }

  h3 {
    font-size: 20px;
    margin: 30px 0 20px;
  }

  p {
    line-height: 2;

    + p {
      margin-top: 20px;
    }
  }
}
.article-content {
  padding-bottom: 50px;
}
.article-image {
  height: 200px;
  width: 450px;
  margin-bottom: 10px;
  display: inline-block;

  p {
    padding-bottom: 15px;
  }

  img {
    height: 150px;
    box-shadow: 12px 20px 25px 0 rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    border: 0;
  }

  iframe {
    display: block;
    width: 83%;
    box-shadow: 12px 20px 25px 0 rgba(0, 0, 0, 0.15);
    border-radius: 4px;
  }

  .image-link {
    font-size: 13px;
    padding-left: 3px;
  }

  #image1,
  #image2,
  #image3 {
    opacity: 0;
  }
}
.article-about {
  display: inline-block;
  padding-top: 35px;
  vertical-align: top;
  max-width: 55%;

  .detail {
    font-size: 14px;
    padding: 35px 0 0 25px;
    list-style-type: square;

    li {
      padding-top: 10px;
      line-height: 12px;
    }
  }
}
.article-detail {
  font-size: 14px;
  padding-bottom: 45px;
}
.effect-fade-side {
  animation-name: fade-in-side;
  animation-duration: 2s;
  animation-iteration-count: 1;
}

@keyframes fade-in-side {
  from {
    opacity: 0;
    transform: translate3d(10%, 0, 0);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

Vue

new Vue({
  el: "#app",
  mounted() {
    const scene1 = this.$scrollmagic
      .scene({
        triggerElement: '#trigger1',
        triggerHook: 0.5,
        offset: 100,
        duration: 300,
        reverse: false
      })
      .setTween('#image1', {
        css: {
          opacity: '1'
        }
      })

    const scene2 = this.$scrollmagic
      .scene({
        triggerElement: '#trigger2',
        triggerHook: 0.5,
        offset: 100,
        duration: 300,
        reverse: false
      })
      .setTween('#image2', {
        css: {
          opacity: '1'
        }
      })

    const scene3 = this.$scrollmagic
      .scene({
        triggerElement: '#trigger3',
        triggerHook: 0.5,
        offset: 100,
        duration: 300,
        reverse: false
      })
      .setTween('#image3', {
        css: {
          opacity: '1'
        }
      })

    this.$scrollmagic.addScene([scene1, scene2, scene3])
  }
})