[BUG] AnimatePresence: Incorrect transition when using spring type positionTransition
Describe the bug I came across this bug trying to replicate the same functionality of PoseGroup in react-pose using AnimatePresence and positionTransition in framer-motion instead. In both cases, the goal is the perform layout transition when adding and removing items inside a flexbox.
react-pose (PoseGroup): https://codesandbox.io/s/elegant-sara-6htck framer-motion: https://codesandbox.io/s/nostalgic-carson-kezqg
In the framer-motion example, positionTransition is used in AnimatePresence to animate layout change when adding and removing items inside flexbox. The codesandbox link will show the default case (which looks like a tween) and a spring type transition.
If the Red box is toggled AFTER the unmount animation starts and BEFORE the animation finishes and completely unmounts, the spring transition target veers off course for a moment before correcting itself.
I've created some BUG buttons that toggles with specific timings to replicate this bug in the codesandbox link.
To Reproduce
- Go to https://codesandbox.io/s/nostalgic-carson-kezqg
- Click on BUGS buttons
Expected behavior In the documentation, https://www.framer.com/api/motion/migrate-from-pose/#posegroup
Paired with AnimatePresence, you have all the previous functionality of PoseGroup.
The flipMove animation from PoseGroup should be replicable with AnimatePresence and positionTransition. (If not, then consider this a feature request).
It looks like PoseGroup is able to bring the exiting component outside the layout the instance it starts its exiting transition. The remaining components is therefore able to immediately transition to its new layout
However, AnimatePresence will wait for the exiting component to finish its transition before leaving the layout causing a delay in the positionTransition of the remaining components in the layout.
Implementing this feature may solve the bug described above
Desktop (please complete the following information): OS - windows 10 Browser - chrome
The second part of this PR is basically a popFromFlow functionality that we can track here: https://github.com/framer/motion/issues/296
The actual bug here is we don't seem to be correctly resetting the velocity of our FLIPped elements and that velocity gets incorporated into the subsequent animation. I'm not sure why y has any velocity in the above example. I think this can be fixed by measuring x/y velocity at the start of the flip animation and applying that to the subsequent animation.
Oh just realised this is fixed in the latest version. I'm going to look into how we reincorporate velocity but closing this.
We do reincorporate velocity correctly :+1: