Jump to content
Search Community

Tweening an Object Along a Bezier Curve Based on User Scroll

SammyC123 test
Moderator Tag

Go to solution Solved by Carl,

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

Is it possible to advance the tween of the car moving down the path based on the user's scroll, or do I need an additional library (e.g. ScrollMagic) to accomplish this?

 

To reiterate/clarify, if the user presses the down arrow or uses their scroll wheel, I want the car to move down the path.  I would like to solve this problem purely with GreenSock.

See the Pen EKKyxa by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution

when it comes to scroll-driven animation, you can't beat using ScrollMagic with GSAP.

 

However, if you want to roll your own solution the basic mechanics of controlling a tween or timeline via scroll can be seen here:

 

http://codepen.io/adrianparr/pen/mbrqt

 

The basic idea is that you convert the scroll position to a value (between 0 and 1) that you pass to the progress() of a tween or timeline.

 

However, its best not to attach functions directly to the scroll event as they can fire way more often than you need and can impact performance.

This pen by Diaco illustrates how to throttle the callbacks that get fired from scroll or resize: http://codepen.io/MAW/pen/yewOgZ

  • Like 4
Link to comment
Share on other sites

Curiously, I tried replicating this ScrollMagic example on Codepen to play around with it, and while it works just fine, the smoothness of the animations is vastly subpar.  Any idea why that would be?  I think it has something to do with the viewport, but I'm uncertain.  I know this is probably outside the scope of your support, but I thought you might know off-hand why it would be occurring.

 

Here's my version:  

See the Pen VajVNW by anon (@anon) on CodePen

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