fix: tabs can not scroll at mobile, close #4828
parent
9f5ac8d441
commit
42afcbbfbc
|
@ -33,26 +33,26 @@ export default function useTouchMove(
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const { screenX, screenY } = e.touches[0];
|
const { screenX, screenY } = e.touches[0];
|
||||||
setTouchPosition({ x: screenX, y: screenY });
|
|
||||||
const offsetX = screenX - touchPosition.value.x;
|
const offsetX = screenX - touchPosition.value.x;
|
||||||
const offsetY = screenY - touchPosition.value.y;
|
const offsetY = screenY - touchPosition.value.y;
|
||||||
onOffset(offsetX, offsetY);
|
onOffset(offsetX, offsetY);
|
||||||
|
setTouchPosition({ x: screenX, y: screenY });
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
setLastTimestamp(now);
|
|
||||||
setLastTimeDiff(now - lastTimestamp.value);
|
setLastTimeDiff(now - lastTimestamp.value);
|
||||||
|
setLastTimestamp(now);
|
||||||
setLastOffset({ x: offsetX, y: offsetY });
|
setLastOffset({ x: offsetX, y: offsetY });
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTouchEnd() {
|
function onTouchEnd() {
|
||||||
if (!touchPosition.value) return;
|
if (!touchPosition.value) return;
|
||||||
|
const lastOffsetValue = lastOffset.value;
|
||||||
setTouchPosition(null);
|
setTouchPosition(null);
|
||||||
setLastOffset(null);
|
setLastOffset(null);
|
||||||
|
|
||||||
// Swipe if needed
|
// Swipe if needed
|
||||||
if (lastOffset.value) {
|
if (lastOffsetValue) {
|
||||||
const distanceX = lastOffset.value.x / lastTimeDiff.value;
|
const distanceX = lastOffsetValue.x / lastTimeDiff.value;
|
||||||
const distanceY = lastOffset.value.y / lastTimeDiff.value;
|
const distanceY = lastOffsetValue.y / lastTimeDiff.value;
|
||||||
const absX = Math.abs(distanceX);
|
const absX = Math.abs(distanceX);
|
||||||
const absY = Math.abs(distanceY);
|
const absY = Math.abs(distanceY);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue