Jump to content
GreenSock

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

Draggable while scaling issue

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

Just finished making these two short codepens to demonstrate. This Draggable has a separate drag handle for the drag item, and on release it scales the entire drag item up.

 

If you click on the handle while it's scaled up, I want the item to shrink back to it's normal size only while you are dragging. However, I can't figure out how to make it stay under your mouse where you actually clicked the handle.

 

codepen 1 - instantly scale-down: https://codepen.io/anon/pen/VerJdJ

codepen 2 - animate scale-down (this is what i would prefer if possible): 

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

 

I thought maybe while scaling, if I could change the transform origin to where the mouse pointer is that would fix it, but unfortunately there are other coordinates in the application that rely on the transformOrigin being 50%, 50%.

 

Is there a way to do this?

 

Outcome:

1.) The item shrinks but is no longer under your mouse pointer. Even attempting to relocate it manually seems wonky (see codepen and other things I have tried below)

 

Expected Outcome:

1.) the item shrinks and remains attached at the same offset to the mouse (appearing to scale at your mouse point, as if your mouse point were the origin)

 

Things I have tried:

1.) in the onDragPress, I attempted to get the the mouse coordinates within the drag target's container and instantly relocate the item to those coordinates. That results in bazaar behavior.

2.) I've attempted calling myDraggable.update() before and during setting the scalethe scale animation, and onDragMove

 

 

Any help is appreciated, thanks a lot in advance!

 

Also, let me say: TimelineLite and TweenLite are some of the most incredible libraries I've used. Pushing my company to purchase a member license.

Share this post


Link to post
Share on other sites

Thank you! Seems to work very nicely even with the animation.

I was initially not willing to change the transform origin due to other constraints, but they're easier to work around than this would otherwise be.

 

I will note, if you rotate the drag item in addition to scaling, this stops working as expected. Fortunately I was able to talk my project managers into getting rid of the rotation.

 

Thank you again

  • Like 1

Share this post


Link to post
Share on other sites

You could add rotation by keeping the origin in the center and using translation instead. I think the problem you had is that you weren't adjusting the coordinates for the scale factor.

  • Like 1

Share this post


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

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. 


  • Recently Browsing   0 members

    No registered users viewing this page.

×