Message List: Fix swipe-to-back on iOS triggering reply action (#456)
This commit is contained in:
parent
b71f854a2d
commit
0f7d0b0625
@ -125,6 +125,8 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) {
|
|||||||
const minZoom = options.minZoom ?? 1;
|
const minZoom = options.minZoom ?? 1;
|
||||||
const maxZoom = options.maxZoom ?? 4;
|
const maxZoom = options.maxZoom ?? 4;
|
||||||
|
|
||||||
|
let isNearEdge = false;
|
||||||
|
|
||||||
function onCapture(e: MouseEvent | RealTouchEvent) {
|
function onCapture(e: MouseEvent | RealTouchEvent) {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
const {
|
const {
|
||||||
@ -162,6 +164,11 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) {
|
|||||||
document.addEventListener('mousemove', onMove);
|
document.addEventListener('mousemove', onMove);
|
||||||
document.addEventListener('mouseup', onRelease);
|
document.addEventListener('mouseup', onRelease);
|
||||||
} else if (e.type === 'touchstart') {
|
} else if (e.type === 'touchstart') {
|
||||||
|
if (IS_IOS) {
|
||||||
|
const x = (e as RealTouchEvent).touches[0].pageX;
|
||||||
|
isNearEdge = x <= IOS_SCREEN_EDGE_THRESHOLD || x >= windowSize.get().width - IOS_SCREEN_EDGE_THRESHOLD;
|
||||||
|
}
|
||||||
|
|
||||||
// We need to always listen on `touchstart` target:
|
// We need to always listen on `touchstart` target:
|
||||||
// https://stackoverflow.com/questions/33298828/touch-move-event-dont-fire-after-touch-start-target-is-removed
|
// https://stackoverflow.com/questions/33298828/touch-move-event-dont-fire-after-touch-start-target-is-removed
|
||||||
target.addEventListener('touchmove', onMove, { passive: true });
|
target.addEventListener('touchmove', onMove, { passive: true });
|
||||||
@ -249,6 +256,7 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) {
|
|||||||
y: newWindowSize.height / 2,
|
y: newWindowSize.height / 2,
|
||||||
};
|
};
|
||||||
captureEvent = undefined;
|
captureEvent = undefined;
|
||||||
|
isNearEdge = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMove(e: MouseEvent | RealTouchEvent) {
|
function onMove(e: MouseEvent | RealTouchEvent) {
|
||||||
@ -313,12 +321,8 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSwipe(e: MouseEvent | RealTouchEvent, dragOffsetX: number, dragOffsetY: number) {
|
function onSwipe(e: MouseEvent | RealTouchEvent, dragOffsetX: number, dragOffsetY: number) {
|
||||||
// Avoid conflicts with swipe-to-back gestures
|
if (IS_IOS && isNearEdge) {
|
||||||
if (IS_IOS) {
|
return false;
|
||||||
const x = (e as RealTouchEvent).touches[0].pageX;
|
|
||||||
if (x <= IOS_SCREEN_EDGE_THRESHOLD || x >= windowSize.get().width - IOS_SCREEN_EDGE_THRESHOLD) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const xAbs = Math.abs(dragOffsetX);
|
const xAbs = Math.abs(dragOffsetX);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user