motion icon indicating copy to clipboard operation
motion copied to clipboard

Manual drag end

Open JakeGilesPhillips opened this issue 2 years ago • 4 comments

I am trying to make a component that follows the mouse to an extent on hover then snaps back to its position after a certain trigger. In my case once the mouse has passed a certain distance from the original component. I am able to trigger the drag effect on hover, and using constraints and elastic I am having the desired effect.

The problem is I cannot end the drag animation as the drag controls don't expose the stop() function.

Describe the solution you'd like useDragControls() to expose both the start and stop functions so the drag can be manually ended.

Additional context See the light/dark toggle in the bottom left of this site for example https://www.jomor.design/

FAQs

Does Framer Motion support Preact?

It might work with Preact, but we don't explicitly support it, so if it does currently work you'd be using it at your own risk.

JakeGilesPhillips avatar Oct 23 '23 21:10 JakeGilesPhillips

Hi, I want to work on this. Please assign this issue to me.

Anubhav-Chauhan3367 avatar Oct 24 '23 10:10 Anubhav-Chauhan3367

Were you ever able to find a solution to this @JakeGilesPhillips?

p4nthera115 avatar Jun 19 '24 13:06 p4nthera115

+1

wkd-kapsule avatar Jul 09 '24 02:07 wkd-kapsule

Any news about this?

nelsongollop avatar Jul 22 '24 19:07 nelsongollop

I believe this shipped in v12.21.0

changelog: https://github.com/motiondivision/motion/blob/main/CHANGELOG.md#added-2 docs: https://motion.dev/docs/react-use-drag-controls#manually-stop-and-cancel

oisinlavery avatar Jul 19 '25 20:07 oisinlavery