小编sti*_*des的帖子

React Native:约束Animated.Value

我正在创建一个React-Native应用程序,方案是这样的:我希望用户能够平移视图,但不是完全按照他想要的方式.我想限制视图在被用户拖动时可以移动多少.

我已经阅读了API PanResponderAnimatedAPI 的文档(多次),但找不到任何可以做到这一点的东西,我也找不到任何其他类似的东西.

限制在响应者的事件中?

onPanResponderMove: Animated.event([null,{
    dx: this.state.pan.x,  //Some function here to constrain the value?
    dy: this.state.pan.y
}]),
Run Code Online (Sandbox Code Playgroud)

应用变换时的约束?

style = {
    transform: {
        transformX: ...,//Use interpolate to constrain the values somehow?
        transformY: ...
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript animation react-native

9
推荐指数
3
解决办法
2957
查看次数

标签 统计

animation ×1

javascript ×1

react-native ×1