This (probably) isn't a bug, rather a question, but it's very related to internals of framer-motion and I doubt it will be answered by someone in Discussions at all.
1. Describe the bug
I have drag-and-drop grid implemented with framer-motion. I have bunch of <Card/> components, each of them positioned using position: absolute, top, left properties (stored in state). They have drag enabled, with dragSnapToOrigin={true}. And in onDragEnd we check drag-end coordinates and if card can be repositioned there (i.e. doesn't overlap with another card), we fire state update of state with top and left. Since dragSnapToOrigin and state update is fired at same time, for user it looks like card just snapped to new position after releasing mouse button.
With frame-locking external event handlers (introduced in #1988), now dragSnapToOrigin triggers immediately, so element snaps to it's initial position after releasing mouse button. But only for a moment, since state update (and thus real reposition) is fired on next frame. This introduces flickering.
I was wondering, is there any way to work around this? I ended up patching package to fire onDragEnd right away, but I wanted to ask maybe there is better solution and to generally bring this (potential) issue to your attention.
This (probably) isn't a bug, rather a question, but it's very related to internals of framer-motion and I doubt it will be answered by someone in Discussions at all.
1. Describe the bug
I have drag-and-drop grid implemented with framer-motion. I have bunch of
<Card/>components, each of them positioned usingposition: absolute,top,leftproperties (stored in state). They havedragenabled, withdragSnapToOrigin={true}. And inonDragEndwe check drag-end coordinates and if card can be repositioned there (i.e. doesn't overlap with another card), we fire state update of state withtopandleft. SincedragSnapToOriginand state update is fired at same time, for user it looks like card just snapped to new position after releasing mouse button.With frame-locking external event handlers (introduced in #1988), now
dragSnapToOrigintriggers immediately, so element snaps to it's initial position after releasing mouse button. But only for a moment, since state update (and thus real reposition) is fired on next frame. This introduces flickering.I was wondering, is there any way to work around this? I ended up patching package to fire
onDragEndright away, but I wanted to ask maybe there is better solution and to generally bring this (potential) issue to your attention.