fix: tabs can not scroll at mobile, close #4828

pull/4842/head
tangjinzhou 2021-11-02 21:23:31 +08:00
parent 9f5ac8d441
commit 42afcbbfbc
1 changed files with 6 additions and 6 deletions

View File

@ -33,26 +33,26 @@ export default function useTouchMove(
e.preventDefault();
const { screenX, screenY } = e.touches[0];
setTouchPosition({ x: screenX, y: screenY });
const offsetX = screenX - touchPosition.value.x;
const offsetY = screenY - touchPosition.value.y;
onOffset(offsetX, offsetY);
setTouchPosition({ x: screenX, y: screenY });
const now = Date.now();
setLastTimestamp(now);
setLastTimeDiff(now - lastTimestamp.value);
setLastTimestamp(now);
setLastOffset({ x: offsetX, y: offsetY });
}
function onTouchEnd() {
if (!touchPosition.value) return;
const lastOffsetValue = lastOffset.value;
setTouchPosition(null);
setLastOffset(null);
// Swipe if needed
if (lastOffset.value) {
const distanceX = lastOffset.value.x / lastTimeDiff.value;
const distanceY = lastOffset.value.y / lastTimeDiff.value;
if (lastOffsetValue) {
const distanceX = lastOffsetValue.x / lastTimeDiff.value;
const distanceY = lastOffsetValue.y / lastTimeDiff.value;
const absX = Math.abs(distanceX);
const absY = Math.abs(distanceY);