kswedberg / jquery-smooth-scroll

Automatically make same-page links scroll smoothly
MIT License
1.97k stars 427 forks source link

Scroll x pixels #100

Closed Redani closed 7 years ago

Redani commented 8 years ago

Hi, and thanks for this lovely plugin :)

Is it possible to scroll repeatedly X pixels? just like shown on this fiddle: http://jsfiddle.net/xEFq5/13/

thanks

kswedberg commented 7 years ago

It's possible now! :)

You'll need to use the $.smoothScroll() method and pass in a "relative string" for the pixel amount (for example, "+=60px"). More info is now in the readme and on the main demo page.

Let me know if you run into any problems or have additional questions.

Redani commented 7 years ago

Hi @kswedberg, thanks so much for your reply and apologies for the delay. Cool, that's very nice of you, i'll try it out as soon as I can and will let you know if I run into any problems ;) Cheers

kswedberg commented 7 years ago

No problem, @Redani. If it works for you, would you mind closing this issue? Thanks!

Redani commented 7 years ago

Hi, I have just tried to make it work but didn't succeed :/ here is my code:

$(document).on("click", "ul.to_scroll > li a.down", function() {
    $.smoothScroll('+=' + $("ul.to_scroll").height());
});

it scrolls the whole page!

Also is there a callback function that could trigger when the scrolling reaches the end?

Thanks

kswedberg commented 7 years ago

Not sure why it's not working for you. Can you give me a URL to look at?

kswedberg commented 7 years ago

As for the callback function, use afterScroll:

$.smoothScroll({
  afterScroll: function() {
     console.log('hello!')
  }
}, '+=' + $("ul.to_scroll").height());
kswedberg commented 7 years ago

Closing this due to inactivity.