Jump to content
Search Community

Animation not playing

Vincentccw 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

You added the animation property to the DOM element, but tried to access it from the jQuery collection (which is an array containing DOM elements). You're looking for:

$(".as").prop('animation').play();
// or
$(".as")[0].animation.play();

Also Chrysto, why do you think it's a bad idea to store the data there? Any namespace issues exist at the global window level as well, and I can't think of any other downsides.

Link to comment
Share on other sites

Hi, it is a generally bad idea to store data in DOM/jQuery elements. Why don't you do

See the Pen KLvCi by bassta (@bassta) on CodePen

instead? 

Thanks for the solution, however I'm trying to animate the button individually.

 

If I use your method, I don't think I can workaround it

 

here is the revised pen:

See the Pen ?editors=101 by vincentccw (@vincentccw) on CodePen

Link to comment
Share on other sites

Hi,

 

Here is what I would do: 

See the Pen fxKyD by bassta (@bassta) on CodePen

As Jamie pointed, the problem is that you're assigning the animation to the original DOM object, which you can get with $selector[0] or $selector.get(0)

 

@Jamie, in some cases it can have impact on performance and also gets very messy with scoping. Most of the times there's a better way to accomplish the same results. 

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