Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
JohnH

Animate before Drag

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 there,

 

new to the forum, so first of all thanks for having me! I'm also new to gsap as well.

 

The question I have is; Whenever I use 'Draggable' and I want to animate the object or element that is being dragged, I want to have it animate onmousedown so that as soon as the object is touched it expands. How can I do this as I've always had my animations run when the object is moved instead of animating before being moved. Is there a clever way gsap can do this or do I need to add a mousedown function?

 

Thanks in advance,

John

See the Pen WXNXzv by anon (@anon) on CodePen

Link to comment
Share on other sites

Apologies, didn't realise anonymous pens couldn't be embedded!

Link to comment
Share on other sites

You can use onPress event of draggable, it triggers on mousedown.

 

 

See the Pen ZaEamK by Sahil89 (@Sahil89) on CodePen

 

  • Like 2
Link to comment
Share on other sites

Thanks for the reply Sahil, I didn't know this existed. However the issue I have with this is the animation isn't always reversed?

Link to comment
Share on other sites

Oh right, use onRelease event instead of onDragEnd.

  • Like 3
Link to comment
Share on other sites

Perfect Sahil, Sorry to be a bother, thanks very much!

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