【问题标题】:react-spring - set the initial value of an interpolationreact-spring - 设置插值的初始值
【发布时间】:2020-09-25 22:45:53
【问题描述】:

下面的动画将从1 变为2

const [props, set] = useSpring(() => ({ value:1 }));
set({value: 2});

但是,我们假设我希望立即将值更改为3,然后以动画方式更改为2,无论它当前是什么。换句话说,我想避免 1 和 3 之间的平滑插值。

const [props, set] = useSpring(() => ({ value:1 }));
set({value: 3, immediate: true}); //doesn't seem to work.
set({value: 3});

我该怎么做?

【问题讨论】:

    标签: react-spring


    【解决方案1】:
    const [props, set] = useSpring(() => ({ value:1 }));
    set({from: {value: 3}, value:2, reset: true});
    

    【讨论】:

      猜你喜欢
      • 2020-03-08
      • 1970-01-01
      • 2017-04-14
      • 2018-12-25
      • 2019-01-23
      • 2016-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多