Jump to content
Search Community

Animating with the new KineticJS

Michael71 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 was working with the new KineticJS version and the 2D Physics from GSAP.

 

Although there is no visible error, I can't seem to animate an element the way I used to, with TimelineMax/Lite and "onUpdate:stage.draw", "onUpdateScope:stage"

Anyone has any ideas or has faced similar problem?

 

I have set up a codepen here: http://cdpn.io/lzkbu

 

Thanks in advance!

 

Link to comment
Share on other sites

Hi Michael,

 

I see the problem. I don't know how familiar you are with KineticJS, but Kinetic objects don't have x and y properties. They have setX(), setY(), getX() and getY() methods.

 

The physics2D plugin assumes you mean to change the x/y properties of the target object (which Kinetic objects don't have).

 

The plugin is very flexible and allows you to specify the yProp and xProp (see docs)

 

 

 

TweenMax.to(dot,2,{physics2D:{
      velocity:getRandom(80, 380), 
      angle:-10, 
      gravity:400,
     xProp:"setX",
     yProp:"setY"
    }
    }));

 

I modified your code and forked your pen

 

See the Pen baae401528b749d711124008bace83ca by GreenSock (@GreenSock) on CodePen

  • 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.
×
×
  • Create New...