Jump to content
Search Community

Use an input value to change animation speed

Jon Burdon test
Moderator Tag

Recommended Posts

I want to grab the value selected on a range slider and use it to change the speed of my tween.

 

I'm new to this, so I'm hoping this is a simple one. It looks like I need to refresh or restart the animation every time I change the value of the slider.

 

In the example here, tl2 is restarted and played when the button 'Shot 2' is clicked... but the variable called speed (grabbed from the slider) doesn't seem to ever be updated in the tween.

See the Pen gOBGJQr by jonburdon (@jonburdon) on CodePen

Link to comment
Share on other sites

Hi @Jon Burdon and welcome to the GreenSock forums!

 

In this cases is better to use fromTo instances and create them in the click events, that because GSAP will record the values on the first render and that could lead to odd results in the animations.

 

Here is a fork of your codepen:

See the Pen QWZOmEa by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps.

Happy Tweening!

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