Share Posted January 20, 2016 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: 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. See the Pen VerJdJ by anon (@anon) on CodePen Link to comment Share on other sites More sharing options...
Share Posted January 20, 2016 Just change its transform origin... See the Pen 355b222b24285bbf5ae51dc4b218ec22 by osublake (@osublake) on CodePen 5 Link to comment Share on other sites More sharing options...
Author Share Posted January 20, 2016 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 1 Link to comment Share on other sites More sharing options...
Share Posted January 21, 2016 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now