Jump to content
Search Community

drag, snap, scroll and more

benoit test
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

As I understand it this could be a bit tricky or messy.

 

The key to getting the scrollY of the window to effect the movement of the box is to use ThrowPropsPlugin.track() method to track the velocity of the scrolling.

When the user is done scrolling you can create a tween of the box based on the velocity of the scrolling.

 

Definitely study the ThrowPropsPlugin docs: https://greensock.com/docs/Plugins/ThrowPropsPlugin 

and the track() method: https://greensock.com/docs/Plugins/ThrowPropsPlugin/static.track()

 

Here is a very rough implementation that will allow you to gently use a trackpad to move the red box.

 

See the Pen oPBxgQ?editors=0010 by GreenSock (@GreenSock) on CodePen

 

I suspect you will need to do some work to update the Draggable and prevent things from getting too crazy. Right now its very easy to throw the thing very far. Also if you grab the vertical scrollbar and move it nothing very good happens.

 

 

Unfortunately this isn't the type of thing I can spend hours on working out all the kinks. Hopefully this is enough to at least spark some ideas about what is possible with the API

 

 

 

  • Like 5
Link to comment
Share on other sites

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...