Jump to content


TimelineMax not incrementing x value with +=

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

Hi all,


Im having trouble triggering my 'slideshow', i got the basics working with the timeline, but whenever i restart it, the 'x : ''-='' doenst add the amount, but starts from the previous x value.

I have a 'activeCount' variable running, which disables the buttons when the max amount of slides is reached.
This part works fine in the console, but ofcourse not really visible when the timeline isn't working correctly.

Can someone help me with this?


See the Pen jKWQGa by chrissnoek (@chrissnoek) on CodePen

Link to comment
Share on other sites

Hi @sirhc, it's because your restarting the same timelines with values that were calculated at the start. To introduce new values, you can use a function based value for `x` or you can just make these Tweens within the `onclick` handler rather than Timelines.


See the Pen oybJOG?editors=1111 by sgorneau (@sgorneau) on CodePen

Edit: CodePen fixed



  • Like 2
Link to comment
Share on other sites

My CodePen is botched ... I’ll fix it up and repost in a few :)

Link to comment
Share on other sites

1 hour ago, sirhc said:

@Shaun Gorneau Thanks a ton, got it working myself!

See the Pen RJrdzo by chrissnoek (@chrissnoek) on CodePen


OK, great! I have updated the embedded pen (I somehow forked multiple times and it got messed up ... should have had coffee before I started :) )


But, I'm glad you got it figured out!

  • Like 1
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.