fix(all): gestures should use a passive listener (#21038)

This commit is contained in:
Liam DeBeasi
2020-04-30 16:03:54 -04:00
committed by GitHub
parent eab3373213
commit dea9248763
4 changed files with 8 additions and 13 deletions

View File

@@ -2,7 +2,6 @@ import { Component, ComponentInterface, Event, EventEmitter, Host, Listen, Prop,
import { getIonMode } from '../../global/ionic-global';
import { GESTURE_CONTROLLER } from '../../utils/gesture';
import { now } from '../../utils/helpers';
@Component({
tag: 'ion-backdrop',
@@ -14,7 +13,6 @@ import { now } from '../../utils/helpers';
})
export class Backdrop implements ComponentInterface {
private lastClick = -10000;
private blocker = GESTURE_CONTROLLER.createBlocker({
disableScroll: true
});
@@ -49,18 +47,9 @@ export class Backdrop implements ComponentInterface {
this.blocker.unblock();
}
@Listen('touchstart', { passive: false, capture: true })
protected onTouchStart(ev: TouchEvent) {
this.lastClick = now(ev);
this.emitTap(ev);
}
@Listen('click', { passive: false, capture: true })
@Listen('mousedown', { passive: false, capture: true })
protected onMouseDown(ev: TouchEvent) {
if (this.lastClick < now(ev) - 2500) {
this.emitTap(ev);
}
this.emitTap(ev);
}
private emitTap(ev: Event) {

View File

@@ -66,6 +66,7 @@ export class PickerColumnCmp implements ComponentInterface {
gestureName: 'picker-swipe',
gesturePriority: 100,
threshold: 0,
passive: false,
onStart: ev => this.onStart(ev),
onMove: ev => this.onMove(ev),
onEnd: ev => this.onEnd(ev),

View File

@@ -26,6 +26,7 @@ export const createGesture = (config: GestureConfig): Gesture => {
const notCaptured = finalConfig.notCaptured;
const onMove = finalConfig.onMove;
const threshold = finalConfig.threshold;
const passive = finalConfig.passive;
const blurOnStart = finalConfig.blurOnStart;
const detail = {
@@ -204,6 +205,7 @@ export const createGesture = (config: GestureConfig): Gesture => {
pointerUp,
{
capture: false,
passive
}
);

View File

@@ -7,7 +7,10 @@ export const createPointerEvents = (
pointerDown: any,
pointerMove: any,
pointerUp: any,
options: EventListenerOptions
options: {
passive?: boolean;
capture?: boolean
}
) => {
let rmTouchStart: (() => void) | undefined;