Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Vincentccw

Cannot trigger animation using a button

Recommended Posts

I'm trying to create a simple animation with a trigger button using TimelineLite(), but some how I got stuck...

 

Here is my pen:

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

 

I can trigger the animation when I hover over the red square but not the button itself (since the animation is store inside the square instead of the button)

 

Thanks for the help in advance

Link to post
Share on other sites

Hi,

 

Your problem is that you assign the timeline to the element with id of of a "box", but on the mouseenter event listener this points to the element with id button. You have to declare the timeline variable and then access it in the mouseenter event listener;

 

Here is example how to to this: 

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

  • Like 2
Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×