Scrollify 获取每个页面以对其进行动画处理

Scrollify get each page to animate it

我必须使用正在使用 jQuery 的库 Scrollify.js(不幸的是)。在特定部分滚动时,我需要在某些 div 上添加 class。我正在尝试根据动画 divs.

获取每个页面

我知道我在滚动所有部分之前和之后都有一个事件,但每个部分都需要 independant/specific。 这是一个 JSFiddle 演示

$(function() {
  $.scrollify({
    section: ".panel",
    before: function(nextIndex, elements) {
//      alert('before event was sent');
    },
    after: function(index) {
//      alert('after is triggered here');
    }
  });

  $(".scroll,.scroll-btn").click(function(e) {
    e.preventDefault();

    $.scrollify.next();
  });
});

来自 github 的作者,它 looks like this 但让我感到困惑...

 before: function(i,panels) {
            var ref = panels[i].attr("data-section-name");


            panels[i].find(".gallery0,.gallery1,.gallery2").addClass("moved");


            if(ref==="design") {
                $(".features").find(".gallery0,.gallery1,.gallery2").removeClass("moved");
                $(".ios7 .gallery0").css("top",0);
            }
            if(ref==="features") {
                $(".ios7 .content").removeClass("moved");
                initialPosition();
            }
            if(ref==="ios7") {
                $(".ios7 .content").addClass("moved");

                $(".ios7 .gallery0").css("top",0);
            }
        },
        after:function(i,panels) {
            var ref = panels[i].attr("data-section-name");

            if(ref==="home") {
                $(".design").find(".gallery0,.gallery1,.gallery2").removeClass("moved");
            }
        }
    });

您可以使用 $.scrollify.current() 到 select 当前滚动的部分并向其添加 class

JsFiddle

if($.scrollify.current().attr('data-section-name')=="configuration")
{
   $.scrollify.current().addClass('config');
}