const Item = posed.div({
enter: {x: 0, opacity: 1},
exit: {x: 1000, opacity: 0}
});
<PoseGroup>
<Item key={whatever}></Item>
</PoseGroup>
目前,当我从列表中删除某个项目时,姿势组 div 会变短,并且该项目会同时滑出。如何告诉姿势组等到项目完成动画后再更新姿势组的高度?要延迟某个项目,您可以在配置中添加延迟
,但如何延迟姿势组?
最佳答案
您面临的问题是,PoseGroup
将每个现有元素设置为 position:absolute
,这使其脱离了元素的自然流动。这就是为什么其他元素立即跳起来的原因。
PoseGroup
提供了一个名为 flipMove
的 Prop 来关闭此功能。
<PoseGroup flipMove={false}>
When an element exits, Pose takes it out of the layout and applies position: absolute so it can detect the new position of surrounding elements and animate via FLIP.
While it attempts to figure out the correct matching transform-origin there are times when this fails. Setting flipMove={false} will prevent these issues.
来源:https://popmotion.io/pose/api/posegroup/
这是您的代码的工作示例:https://codesandbox.io/s/jovial-beaver-3o6m3
关于javascript - react 姿势延迟姿势组高度转换,直到 children 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58657821/