react-pose delay the pose group height transition until after children

我怕爱的太早我们不能终老 提交于 2021-01-27 17:33:19

问题


const Item = posed.div({
  enter: {x: 0, opacity: 1},
  exit: {x: 1000, opacity: 0}
});

<PoseGroup>
  <Item key={whatever}></Item>
</PoseGroup>

Currently when I remove an item from the list, the pose group div gets shorter and the item slides out at the same time. How do I tell the pose group to wait until item has finished animating before updating the height of the pose group? To delay an Item, you add delay to the config, but how do I delay a pose group?


回答1:


The issue you're facing is that the PoseGroup sets each exiting element to position: absolute which takes it out of the natural flow of elements. This is why the other elements jump up immediately.

PoseGroup provided a prop to turn off this feature called flipMove.

<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.

Source: https://popmotion.io/pose/api/posegroup/

Here's a working example of your code: https://codesandbox.io/s/jovial-beaver-3o6m3



来源:https://stackoverflow.com/questions/58657821/react-pose-delay-the-pose-group-height-transition-until-after-children

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!