Jump to content
GreenSock

d11202

Stopping a throw animation

Go to solution Solved by Diaco,

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

Hi

 

Can anyone tell me if there's a 'best practices' way of stopping a throw animation.

 

Basically I want an element to be able to catch something that a player has thrown using the Draggable / ThrowPropsPlugIn. If the element catches the thrown object, the thrown object would stop short of the distance it would have glided (been thrown).

 

Many thanks in advance

 

Link to comment
Share on other sites

HI d11202 :),

 

I think the best practice would depend on what you're hoping to accomplish. 

 

If I'm understanding your question, I'd guess you'll want to set up some bounds for the draggable along with a snap array and maybe a hit test? 

 

Do you happen to have a CodePen available with your basic layout? That would definitely help everyone as they attempt to answer your questions. 

http://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/

 

You've probably seen the draggable docs page, but just in case - lots of good reading here:

http://greensock.com/docs/#/HTML5/Drag/Draggable/

 

Happy tweening. :)

  • Like 1
Link to comment
Share on other sites

  • Solution

Hi d11202  :)

 

pls check Draggable .tween property : http://greensock.com/docs/#/HTML5/GSAP/Utils/Draggable/tween/

 

you can do something like this :

var D = Draggable.create(target,{
   throwProps:true
});

// and then you can kill draggable throw tween with this :  D[0].tween.kill();
  • Like 4
Link to comment
Share on other sites

Great advice above. 

 

In addition, if you know the object being thrown you can pass it into TweenLite.killTweensOf() 

 

http://greensock.com/docs/#/HTML5/GSAP/TweenLite/killTweensOf/

 

Bottomline is that you technically want to kill() whatever tween is animating the object that was thrown and there are multiple ways of finding that tween.

  • Like 4
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.
×