PullDownToRefresh: fix wheeling switch page

This commit is contained in:
thislight 2024-10-09 18:14:09 +08:00
parent 15e2bf3304
commit c8f2179298

View file

@ -95,7 +95,7 @@ const PullDownToRefresh: Component<{
const scrollTop = (event.target as HTMLElement).scrollTop; const scrollTop = (event.target as HTMLElement).scrollTop;
if (scrollTop >= 0 && scrollTop < 1) { if (scrollTop >= 0 && scrollTop < 1) {
const d = untrack(pullDown); const d = untrack(pullDown);
if (event.deltaY <= 0 || d > 0) event.preventDefault(); if (d > 1) event.preventDefault();
ds = -(event.deltaY / window.devicePixelRatio / 2); ds = -(event.deltaY / window.devicePixelRatio / 2);
holding = d < stopPos(); holding = d < stopPos();
if (wheelTimeout) { if (wheelTimeout) {
@ -129,7 +129,6 @@ const PullDownToRefresh: Component<{
return; return;
} }
const item = event.targetTouches.item(0)!; const item = event.targetTouches.item(0)!;
if (untrack(pullDown) > 0) event.preventDefault();
if (lastTouchId && item.identifier !== lastTouchId) { if (lastTouchId && item.identifier !== lastTouchId) {
lastTouchId = undefined; lastTouchId = undefined;
lastTouchScreenY = 0; lastTouchScreenY = 0;
@ -140,6 +139,7 @@ const PullDownToRefresh: Component<{
if (lastTouchScreenY !== 0) { if (lastTouchScreenY !== 0) {
ds = item.screenY - lastTouchScreenY; ds = item.screenY - lastTouchScreenY;
} }
if (Math.abs(ds) > 1 && untrack(pullDown) > 1) event.preventDefault();
lastTouchScreenY = item.screenY; lastTouchScreenY = item.screenY;
if (released) { if (released) {
released = false; released = false;