Jump to content
Search Community

Best Practice for Setting Vars in the Timeline

Kurrent Kurt 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

Hi. With using sprite sheets I wanted to just set the width, height and background-position properties in CSS and set the rest in javascript with TimelineLite or TimelineMax.

 

Is there a best practice for this?

 

I want to do something like in the following example:

I set all the images to hidden to start then animate with fromTo as needed.

 

I made an example here with 3 different colored boxes, which works great on all browsers.

See the Pen jbKWJg by anon (@anon) on CodePen

 

The issue I am having is that on a DoubleClick banner example using the same technique I am having problems when I restart the timeline just in IE10. When I call tl.restart, any of the fromTo images with immediateRender:false are visible from the beginning instead of having autoAlpha:0.

 

Thanks in advance,

Kurt

 

 

Link to comment
Share on other sites

I saw a couple of problems with that demo: 

  1. You're setting immediateRender in the wrong place (the "from" vars instead of the "to" vars). Any special properties like onComplete, immediateRender, etc. should always be in the "to" vars object. 
  2. You mentioned that just the blue one has immediateRender:false...but the code shows that ALL of them have it. 

I also tried it in IE10 and it seemed to work exactly the way it did in Chrome (or any browser) which I guess you did say in your post (that it works great across browsers). Do you have an example that doesn't work?

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