如何解决我该如何解决交换错误,当我滑动直到las元素时,该错误会使我向后移动几步?
所以,我在这里创建了一个刷卡:
let numbers = new Array(40);
for (i = 0,num = 5; i < numbers.length; i++,num += 5) {
numbers[i] = num;
}
const TIME_HEIGHT = styles.text.fontSize * 1.34;
const clock = useClock();
const index = useValue(0);
const snapPoints = numbers.map((_,i) => i * -TIME_HEIGHT)
const offsetY = useValue(0);
const y = useValue(0);
const {
gestureHandler,state,velocity,translation
} = usePanGestureHandler();
const to = snapPoint(y,velocity.y,snapPoints);
useCode(
() => [
cond(eq(state,State.ACTIVE),[
set(y,diffClamp(
withDecay({
value: add(offsetY,translation.y),velocity: velocity.y,}),-numbers.length * TIME_HEIGHT + TIME_HEIGHT,0
)),]),cond(eq(state,State.END),timing({ clock,from: y,to })),set(offsetY,y),cond(not(clockRunning(clock)),[
set(index,floor(divide(y,-TIME_HEIGHT))),debug("index",index)
]),],[]
);
它可以完美工作,但是当我滑动到数组的最后一个元素并尝试进一步滑动时,它向后移动了几步。每次向下滑动时,传送到我的时间会增加多久,向上滑动时可以保存此效果。我该如何解决?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。