Jump to content
Search Community

Change vars in TimeLine

Romano test
Moderator Tag

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

Hello

I'm using TimeLineLite.

 

When you resize the window, it is necessary to recalculate the offset. How to do it?

 

Sample:

 

var tl = new TimelineLite({paused: true});
    var tweener = TweenMax.to($("#mylayer"), 10, {left: "-10%", delay: 1});

    $(window).resize(function (e) {
        tweener.updateTo({left:"20%"}, false);
       

    });

 

updateTo - not working (

 

Can u help me?

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

The reason updateTo() is not working is because is not specifically designed to work with plugins values (says so in the docs), in this case the CSS Plugin. For this case what you could do is wrap the values you're updating in a css:{} key:pair in the config object, like this:

$(window).resize(function (e)
{
  tweener.updateTo( {css:{left:"20%"}}, false);
});

The reason is that as soon as you create the TweenMax instance GSAP creates an object and wraps everything related to the CSS Plugin in that css:{} wrapper, so when you're telling the engine to update those values GSAP can't find them, but if you specify that they reside in the CSS Plugin config object GSAP knows exactly where and what to look for and it updates the values accordingly.

 

That should do the trick.

 

Rodrigo.

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