Search code examples
jquery-scrollify

Use `move` method for neighbouring section, and `instantMove` for non-neighbouring section


Am looking for a way to animate the scrollbar only when moving between neighbouring sections. Scrollify gives you the move and instantMove methods which does that but I need help with the logic of working out whether the section am about to move to is a neighbouring or non-neighbouring section.

Is there way to pass in additional info into the afterRender method or a suggestions to achieve my goal?

afterRender: function() {

 $(".pagination a").on("click", function() {
  $.scrollify.move($(this).attr("href"));
 });
}

Solution

  • Find this example fiddler for reference.

    Here am trying to navigate between sections based on condition, that is targeting section should be nearest to current section. If the targeting section is nearest then scrollify animation will be added by using $.scrollify.move() function, else $.scrollify.instantMove() function will be executed.

    Hope it helps.