Jump to content
GreenSock

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

timeline .paused() attribute doesn't update?

Recommended Posts

Hey roy and welcome to the GreenSock forums.

 

The text doesn't update because you're not telling it to: you call the function to get the value when things are initialized but don't call the method ever again. So it stays on the initial value. You need to create some way of telling it to update.

 

Without using React, I'd create a variable reference to the element whose text should be updated. Then in the playHandler I'd update the text. In React I guess you'd use a ref to do the same thing but I'm not very familiar with React.

Link to post
Share on other sites

Thanks for that, Zach.. I modified and forked the code as shown here, since my next issue is different than this one.
 - now my issue is that I'm not able to toggle the "paused" state correctly. It keeps zipping back to the beginning and re-running.

Could this be an artifact of using fromTo?

 

https://codesandbox.io/s/busy-hooks-8h5gj?file=/src/DemoApp.css

Link to post
Share on other sites

Hey @RoyM, I just did a fork, and also I replaced your masterTL by a useRef() hook, so in this way works. You can check it here: https://codesandbox.io/s/flamboyant-solomon-vdis4

 

const masterTL = useRef(null);

useEffect(() => {
    masterTL.current = gsap.timeline({
      repeat: -1,
      paused: true
    });
}, [masterTL]);

 

  • Like 4
Link to post
Share on other sites

@noviedo - thanks a bunch for that.. I would not have arrived at the idea of a useRef to solve this issue.. works great.

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.

×