Jump to content
Search Community

TweenLite.to execute just once

ZAJDAN 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 have this simple record where I get SVG id's and manipulate with them:

$(window).load(function() {

      var HSCPsvg  = document.getElementById("hscp");
      var svgDoc   = HSCPsvg.contentDocument;
      var JinJang  = svgDoc.getElementById("JinJang");

    JinJang.onclick = function (){
                  TweenLite.to(JinJang, 6, { rotation:360, transformOrigin:"center", ease: Power0.easeNone, repeat:10, });
                };
});

TweenLite works correctly, but for one click only. This method I usually use with jQuery and it works for each click.

How to change it please, so that the rotation will be executed for each mouse click on the selected element?

Thanx

Link to comment
Share on other sites

On first click JinJang rotates to 360, on second click because it is already at 360 it won't animate anymore. try '+=360' but fast clicking will mess up your animation, in that case you fromTo tween and animate from 0 to 360.

 

TweenLite.to(JinJang, 6, { rotation:'+=360', transformOrigin:"center", ease: Power0.easeNone, repeat:10 });

//or try fromTo tween
TweenLite.fromTo(JinJang, 6, {rotation: 0}, { rotation: 360, transformOrigin:"center", ease: Power0.easeNone, repeat:10 });

 

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

12 hours ago, Sahil said:

On first click JinJang rotates to 360, on second click because it is already at 360 it won't animate anymore. try '+=360' but fast clicking will mess up your animation, in that case you fromTo tween and animate from 0 to 360.

 


TweenLite.to(JinJang, 6, { rotation:'+=360', transformOrigin:"center", ease: Power0.easeNone, repeat:10 });

//or try fromTo tween
TweenLite.fromTo(JinJang, 6, {rotation: 0}, { rotation: 360, transformOrigin:"center", ease: Power0.easeNone, repeat:10 });

 

Thank You
the syntax which You sent works well , perfect!
Exist such information in some Official  Documentation?
'How to pass value for parameter rotation' for example.

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