Jump to content
Search Community

smooth scroll

proweb1991
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Posted

that type of scroll hijacking can be kind of disorienting. I don't really do much stuff like that.

However, once you detect which direction and how much the user has scrolled you can generate the appropriate scrollTo tween.

 

I've seen Hamster mentioned a few times for tapping into the mousewheel: http://monospaced.github.io/hamster.js/

 

In the demo below, just scroll down very slowly. you will see how it triggers a scrollTo tween.

 

You would still need to add quite  bit of logic. The mousewheel events fire very often so you my want make sure you aren't creating new tweens all the time or scroll 30 sections in the course of 3 seconds. You would also need to make sure you can scroll the other way too.

 

I used the count variable just as a quick and dirty way to increment how far to scroll. I think you would have to put a bit more thought into this.

We have to keep our support focused on the GSAP API, but maybe the demo below helps a little. Its just a very rough proof concept.

 

See the Pen EbeLgg by hansel234 (@hansel234) on CodePen.

 

  • Like 1
Posted

thank  carl

on window scroll , if can get current section , and find next or prev section ( Detected according to direction ) and run scrollTo with defined id ,  maybe work ...

but how?

i can not detect and run plugin :( 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...