使用 Framer-motion 悬停在父级时为子级设置动画

Arc*_*oob 8 reactjs web-animations react-animations framer-motion

使用成帧器运动,当我悬停在作为按钮的父元素时,我想为我的 Icon 组件设置动画以旋转 90 度。

<motion.button type="button" whileHover={{scale: 1.1}}>
    Visit our Industry 
    {/*Animate this Icon to rotate 90 degrees*/}
    <Icon type="arrow-up" /> 
</motion.button>
Run Code Online (Sandbox Code Playgroud)

我看到了变体的使用,但不确定如何真正将它们与whileHover.

任何帮助将不胜感激,因为这是一个新事物。

zer*_*ero 17

您需要将 'whileHover' 设置为字符串并使用变体进行动画处理。

https://codesandbox.io/s/heuristic-wozniak-2z01b

  • 吃晚饭很方便。为什么这没有标记为答案? (2认同)