Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
andrewandopen

Tween Keeps Resetting

Recommended Posts

Hey Guys,

Having a bit of trouble with an animation here.

I'm using .set() to constantly transform an element using random values. When I scroll I want to transform this element off the page. The scroll animation is being triggered and it's working, but once it's complete it reverts back to it's original position (I think it's because the random value is constantly being created in the background).

How would I overcome this?

Thank you

See the Pen OJVbMjr by andrewandopen (@andrewandopen) on CodePen

Share this post


Link to post
Share on other sites

Hey Andrew and welcome!

 

In most cases like this where you have a constant animation and want to pair another animation with it, it's best to use a container element and animate the two separately. That will save you from having to do a lot of costly calculations trying to pair the two together :) 

 

One way to set it up:

See the Pen jOPVqXL?editors=0100 by GreenSock (@GreenSock) on CodePen

 

Note that I upgraded your syntax to use GSAP 3's syntax since you were loading it anyway.

  • Like 1

Share this post


Link to post
Share on other sites

Side note: GSAP 3 has its own random functionality so you don't have to write your own: 

 

But if you want to keep your own that's cool too :) 

  • Like 1

Share this post


Link to post
Share on other sites

Thank you so much Zach!

I started using GSAP last week for the first time! Have to say your support is amazing! I'm converted!!!!!!

  • Like 1
  • Thanks 1

Share this post


Link to post
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.

×