简体   繁体   English

使用 framer-motion 的 Animated Presence 时出现 Position 错误

[英]Position bug while using framer-motion's Animated Presence

I have a sandbox that is basically a slider made in React, where old data gets replaced by new data every time the user presses the button Next or Previous.我有一个沙箱,基本上是用 React 制作的 slider,每次用户按下按钮 Next 或 Previous 时,旧数据都会被新数据替换。 I want to use framer motion to create some beautiful animations to the slider, and it works almost perfectly.I don't know why, but every time I press the button to got to the next item (or the previous one), the animation shifts the element down and then it goes back to normal.我想使用成帧器运动为 slider 创建一些漂亮的动画,它几乎可以完美运行。我不知道为什么,但每次我按下按钮进入下一个项目(或上一个项目)时,animation将元素向下移动,然后恢复正常。

I'll leave the link to the sandbox below, it will be easier to visualize the bug.我将在下面留下沙箱的链接,这样可以更容易地可视化错误。

Sandbox 沙盒

You must add this props exitBeforeEnter to the AnimatePresence您必须将此道具exitBeforeEnter添加到AnimatePresence

<AnimatePresence exitBeforeEnter initial={false} custom={back}>
// ...
</AnimatePresence>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Framer-motion,在为 x 设置动画时延迟 rotateY - Framer-motion, delay rotateY while animating x 应用运动来反应组件 Framer-Motion - Apply motion to react component Framer-Motion react framer-motion中的退出动画没有出现 - Exit animations in react framer-motion not appearing 如何解决固定的 position 元素在滚动时跳跃 | React JS,成帧器运动 - How to resolve fixed position elements jumps when scrolling | React JS, framer-motion framer-motion,有没有办法在组件渲染后启动 animation,css..etc.. 全部完成 - framer-motion, is there a way to start animation after component's render,css..etc.. all completed 使用拖动道具时,如何让 React Framer-motion 为手机触发 onClick 事件? - How do you get React Framer-motion to fire onClick events for mobiles when using the drag prop? ReactJS:在拖动时计算“操纵杆”的方向(使用 Framer Motion)并根据位置更新 div 效果 - ReactJS: Calculating direction of 'joystick' while dragging (using Framer Motion) and updating div effects depending on position 使用 framer-motion 汇总,isPropValid 情感 function 错误 - Rollup with framer-motion, isPropValid emotion function error 使用 framer-motion 为 react-router 设置动画的问题 - Troubles animating react-router with framer-motion Next.JS with framer-motion 不会改变导航内容 - Next.JS with framer-motion does not change content on navigation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM