ReiniKurobe of Reini
11/11/2019 - 5:56 AM

スクロール Fade in

fade('.js-fade');

function fade(elm) {
  var aniamtionClass = 'is-show';

  var controller = new ScrollMagic.Controller();
  var targets = document.querySelectorAll(elm + ':not(.is-show)');

  if(targets.length < 1) return;

  for (var i = 0; i < targets.length; i++) {
    targets[i].classList.add('fade-' + i);

    var scene = new ScrollMagic.Scene({
      triggerElement: '.fade-' + i,
      triggerHook: 'onEnter',
      reverse: false,
      offset: 100
    })
      .setClassToggle('.fade-' + i, 'is-show')
      //.addIndicators()
      .addTo(controller);
  }
}