Scrolling by sections with the scrollbar
Opened this issue · 3 comments
Hello ! Thank you for this library !
I'd like to scroll section by section also with the scroll bar. Any idea how I could do this ?
Thanks!
Hi @francetus would you be able to clarify what you mean? In this demo you should be able to see the scrollbar on the right-hand side.
Hello @d4nyll
Sorry for beeing unclear ^^
I mean, when we use the srcollbar manuallly, the page scroll also by sections, like with the mouswheel. If you drag/drop the scrollbar, the page stops automatically at the top of the next section. If you drop the scrollbar at the middle of a section, the scrollbar will adjusts automatically.
It will be easier to explain with an example. You can see what I mean here with the plugin Scrollify: https://projects.lukehaas.me/scrollify/
thank you :)
Thanks for clarifying. Unfortunately, that feature isn't supported in smartscroll, and I won't be adding it in the future.
However, if you have the time to invest into modifying the code, feel free to submit a PR. It shouldn't be too hard, here are the steps I would take:
- Add a new option, perhaps call it
snap
- Create a function that detects which section the middle of the screen is touching, get the offset from the top, and run
scrollToPixel
with that offset. - Add a new
if
statement in the code (e.g.if (options.snap === true)
) and in it bind the function defined in (2) to a manual scroll event.