javascript - react 姿势延迟姿势组高度转换,直到 children 之后

标签 javascript reactjs animation popmotion react-pose

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/

相关文章:

reactjs - 如何在静态服务器上托管 ReactJS 项目

CSS如何在当前帧的mouseout上恢复SVG动画

android - 动画 LinearLayout 背景在 Android 中闪烁

javascript - 在 ThreeJS 中从 2D 对象绘制 3D 几何

Javascript if else 语句隐藏和显示 div

javascript - CoffeeScript - 手动声明变量

loops - 如何为SVG动画路径的d制作连续循环

javascript - JavaScript作业题中的自定义排序

javascript - 如何简化 JavaScript/React

reactjs - React Route 不适用于嵌套 URL