0

Two Questions

  1. As the title says, is it possible, with scrollify, to set a different scrollspeed for different sections?

  2. I also have a "scrollify.next" button where I tried changing the scrollspeed, but I realized I'm no jquery/js expert. I managed to overwrite the scrollspeed settings on the button event, but how do I properly return the scrollspeed settings after the click event have finished? As it is now, all scrolling after clicking the button will follow the new setting.

I realise I need to re-learn jquery once again, heh!

$(".next-btn").click(function(e) {
    e.preventDefault();
    $.scrollify.setOptions({
        scrollSpeed: 2500,
    });
    $.scrollify.next();
});

Documentation for scrollify https://github.com/lukehaas/Scrollify

Thanks in advance!

Fredrik Westerlund
  • 133
  • 1
  • 2
  • 10
  • The code seems fine, can you provide more information about your html? – Donald Wu Oct 24 '16 at 03:52
  • Yes, as I said, that code works.But it permanently changes the scrollspeed setting for all the sections after I click the button. I only one that button event to have that specific scrollspeed, after the screen have moved I want the scrollspeed to return to 800. – Fredrik Westerlund Oct 24 '16 at 12:20
  • Then you can define a global variable for ``scrollSpeed``, like ``scrollSpeed: x``.If the current windows screen == next screen you want, set x = 800... – Donald Wu Oct 24 '16 at 14:41
  • Sorry, but that's Chinese for me :/ Are we still talking about Scrollify? – Fredrik Westerlund Oct 24 '16 at 15:13
  • I am talking about js.. you can define a variable for scrollSpeed, like ``scrollSpeed: x``.When you click next button, assign x to a new value – Donald Wu Oct 24 '16 at 15:17
  • That's basically what I've done. I also tried changing it with variables. I have no clue. Basically, when the click event is finished, how do I set the variable back to whatever I want it to be? – Fredrik Westerlund Oct 24 '16 at 16:10
  • i think you need some method from scrollify (http://projects.lukehaas.me/scrollify/#methods-continued), like ``$.scrollify.destroy()`` and ``$.scrollify.current()`` – Donald Wu Oct 24 '16 at 16:17

1 Answers1

2

Use the 'after' callback. Wherever Scrollify scrolls to a section it fires the after callback so you can define a new scroll speed within that for any section you want.

Luke Haas
  • 672
  • 2
  • 6
  • 16
  • Thanks for your reply. I'm trying to understand how to use "after:function(){}". The documentation is very vague, and as i'm no JS/jquery dev(only basic knowledge), I have a hard time understanding how to apply the settings inside that callback. I.E; How to target certain sections, change the speed and how to utilise it. Whenever I put anything inside the after callback, the script stops working, so I guess I do something wrong. Here's what I've created. http://pastebin.com/gAfQRs9H – Fredrik Westerlund Oct 26 '16 at 13:44
  • Try looking at the source of some of Scrollify's example page like: http://projects.lukehaas.me/scrollify/examples/apple it makes use of the after callback to control animations within each section – Luke Haas Oct 26 '16 at 19:19
  • Thanks Luke Haas. I'll look at how you've done and learn from that. You're awesome :) – Fredrik Westerlund Oct 28 '16 at 14:04