react-native - react-native: onPanMove 期间 Animated.View 的动画位置
问题描述
我已经设置了一个动画并想要为视图设置动画,因此当用户触摸移动视图时,视图会在 y 轴上跟随。
我尝试使用 Animated.event 进行设置,但它不起作用。有人可以解释一下 Animated.event 在 panResponder 中是如何工作的吗?
这就是我所拥有的:
const onPanMove = (evt: GestureResponderEvent, state: PanResponderGestureState) => {
Animated.event([null, {dy: new Animated.Value(state.dy)}], {useNativeDriver: true});
};
但什么也没有发生。我也搜索了很多,但没有找到任何好的文档。
当我用它替换event
它时,timing
它可以工作,但它非常滞后,因为它总是等待 touchmove 暂停。
Animated.timing(
this.state.position,
{
toValue: startY - state.dy,
duration: 0,
//easing: this.props.easing,
useNativeDriver: true
}
).start();
解决方案
推荐阅读
- stanford-nlp - 如何从头开始在 gensim 中训练 Glove 嵌入?
- kubernetes - Kubernetes:无法部署简单的“Couchbase”服务
- python - 我需要帮助格式化这些数据
- python - 如何将包含 BST(英国夏令时)的时间戳字符串解析为时区感知的日期时间时间戳?
- celery - 当前运行的 Celery 任务的管理 URL
- asp.net-mvc - ReSharper代码扩展在html剃须刀页面ASP.NET Core MVC中不起作用
- lua - 在lua中查找两个字符串之间的字符串
- texas-instruments - 我的 TI-84 Plus CE-T 计算器是否可以以 surd 形式显示?
- python - Bron-Kerbosch 算法在无向图中找到最大团
- javascript - 如何在我的 Javascript 代码中捕获来自 Metamask 浏览器扩展的锁定/解锁事件?