mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 05:42:44 +08:00
fix: corrected horizontal slip judgment (#8388)
This commit is contained in:
parent
6d428345d7
commit
507adef9b2
@ -42,7 +42,8 @@ export function useTouch() {
|
||||
|
||||
const move = ((event: TouchEvent) => {
|
||||
const touch = event.touches[0];
|
||||
deltaX.value = touch.clientX - startX.value;
|
||||
// Fix: Safari back will set clientX to negative number
|
||||
deltaX.value = touch.clientX < 0 ? 0 : touch.clientX - startX.value;
|
||||
deltaY.value = touch.clientY - startY.value;
|
||||
offsetX.value = Math.abs(deltaX.value);
|
||||
offsetY.value = Math.abs(deltaY.value);
|
||||
|
@ -57,10 +57,22 @@ export function triggerDrag(
|
||||
| VueWrapper<ComponentPublicInstance<any, any, any>>
|
||||
| DOMWrapper<Element>
|
||||
| HTMLElement,
|
||||
x = 0,
|
||||
y = 0
|
||||
relativeX = 0,
|
||||
relativeY = 0
|
||||
) {
|
||||
trigger(el, 'touchstart', 0, 0);
|
||||
let x = relativeX;
|
||||
let y = relativeY;
|
||||
let startX = 0;
|
||||
let startY = 0;
|
||||
if (relativeX < 0) {
|
||||
startX = Math.abs(relativeX);
|
||||
x = 0;
|
||||
}
|
||||
if (relativeY < 0) {
|
||||
startY = Math.abs(relativeY);
|
||||
y = 0;
|
||||
}
|
||||
trigger(el, 'touchstart', startX, startY);
|
||||
trigger(el, 'touchmove', x / 4, y / 4);
|
||||
trigger(el, 'touchmove', x / 3, y / 3);
|
||||
trigger(el, 'touchmove', x / 2, y / 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user