React Spring 中的动画持续时间

Fel*_*ger 3 reactjs react-spring

我有一个相当简单的淡入场景,我想控制动画的持续时间。但无法围绕如何实现这一点。

代码摘录:

function BoxA() {
  return (
    <Spring from={{ opacity: 0.2 }} to={{ opacity: 1 }}>
      {props => (
        <div
          style={{
            height: 100,
            width: 100,
            backgroundColor: "pink",
            color: "#fff",
            ...props
          }}
        >
          1
        </div>
      )}
    </Spring>
  );
}
Run Code Online (Sandbox Code Playgroud)

完整代码示例:https : //codesandbox.io/s/n7pw660264

Pet*_*uzs 6

您必须为持续时间设置配置属性。

<Spring config={{duration: 5000}} from={{ opacity: 0.2 }} to={{ opacity: 1 }}>
Run Code Online (Sandbox Code Playgroud)