Scroll through each page to bring it to life.

I need to work with the Scrollify.js library that uses jQuery (unfortunately). I need to add class

for some div

when scrolling through a specific section. I am trying to get each page in terms of animation divs

.

I know correctly that I have an event before and after scrolling through the entire section, but for each section it needs to be independent / specific. Here is a JSFiddle demo

$(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();
  });
});

      

From the author on github it looks like this , but confused me ...

 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");
            }
        }
    });

      

+3


source to share


1 answer


You can use $.scrollify.current()

to select the currently scrolled section and add a class to it

JsFiddle



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

      

+1


source







All Articles