【问题标题】:How do I start the animation of a block when you scrolled through it in react-spring?当您在 react-spring 中滚动块时,如何启动块的动画?
【发布时间】:2020-07-01 13:31:00
【问题描述】:

如何在 react-spring 中滚动块时启动块的动画?

【问题讨论】:

    标签: reactjs react-spring


    【解决方案1】:

    我喜欢在这个应用程序中使用Waypoint。它是一个组件,您可以将其放置在页面的任何位置。例如到顶部、中部或底部。通常我把它放在我想用它控制的组件之前或之后。它可以在进入页面或离开页面时触发事件。你所能做的就是从这些事件中控制你的 react-spring 动画。例如:

      <Waypoint
        onEnter={() => setScale(true)}
        onLeave={() => setScale(false)}
      />
    

    这是一个小例子:https://codesandbox.io/s/website-logo-animation-with-react-spring-gcqhr

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-08
    • 1970-01-01
    相关资源
    最近更新 更多