Jump to content
Search Community

there is a problem with physics2D and timeline

lzy100p 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

var d1=document.createElement("div")

document.body.appendChild(d1)

d1.style.left="0px"

d1.style.top="0px"

d1.style.width="100px"

d1.style.height="100px"

d1.style.position="absolute"

d1.style.background="#ff0000"

 

var p3to=new TimelineMax({repeat:-1,paused:true})

p3to.to(d1,1,{autoAlpha:1,physics2D: {angle: 0,velocity: 300,gravity: 500}})

p3to.to(d1,0.3,{autoAlpha:0},"-=0.3")

p3to.render(0)

p3to.play()

 

it will throw an error

Uncaught TypeError: Cannot read property 'length' of undefined

See the Pen qqmKWa by lzy100p (@lzy100p) on CodePen

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

Sorry to hear you are having trouble.

Thanks for providing the demo. It was very helpful.

 

The issue seems to be that when the second autoAlpha tween occurs it causes an overwrite on the first tween with autoAlpha and physics2D and somehow things get thrown out of line.

 

In your demo both of your autoAlpha tweens are fading to 0, but in your code above it seems that the first one goes to autoAlpha:1 and the second autoAlpha:0.

I'm not sure what the desired outcome is. If they both go to autoAlpha:0 then one of them is not necessary.

If the first one is supposed to go to autoAlpha:1 then nothing is going to really happen visually as that element is already visible.

 

Regardless of the intention, it seems your demo does show that something odd is going on when the autoAlpha tweens face an overwrite.

 

We will look into this further. 

 

 

For now, you can just schedule the autoAlpha tweens so that they don't overlap like:

 

http://codepen.io/GreenSock/pen/mOmYOX?editors=0010

Link to comment
Share on other sites

Sorry about that! I neglected to update the codepen-specific plugin demo files after we made some updates to improve things in GSAP 1.19.0. It should be fixed now (you may need to clear your cache). To be clear, the "real" plugin files that you'd get from your account in the download zip were fine - it was just the files on the codepen.io CDN that were old. Thanks for letting us know about the issue. Let us know if you run into any other problems. 

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