motiondivision / motion

A modern animation library for React and JavaScript
https://motion.dev
MIT License
25.95k stars 851 forks source link

fix: prevent stop or pause when drag constraints #2758

Open hyesungoh opened 3 months ago

hyesungoh commented 3 months ago

fix #2697

Hello there!

I appreciat your great works 👍

BTW I found some issue at above

as is

https://github.com/user-attachments/assets/1e7a6144-e3bd-4cc1-b45f-f029dda00b74

Element pause or stop when click it while dragging

https://github.com/framer/motion/blob/f59114d4d48f4fbd6a611aba62cd9ebab13e06ab/packages/framer-motion/src/gestures/drag/VisualElementDragControls.ts#L101-L103

I think it was problem

to be

https://github.com/user-attachments/assets/cbb9e925-30d1-4122-8ac6-eede4ef80765

So I prevent stop or pause animation when having dragConstraints

            // Stop or pause any animations on both axis values immediately when not using dragConstraints.
            // This allows the user to throw and catch the component.
            if (!dragConstraints) {
                dragSnapToOrigin ? this.pauseAnimation() : this.stopAnimation()
            }

If you think of any related issues, please share them with me!

Thank you! 😄