mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(all): gestures should use a passive listener (#21038)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@ export const createPointerEvents = (
|
||||
pointerDown: any,
|
||||
pointerMove: any,
|
||||
pointerUp: any,
|
||||
options: EventListenerOptions
|
||||
options: {
|
||||
passive?: boolean;
|
||||
capture?: boolean
|
||||
}
|
||||
) => {
|
||||
|
||||
let rmTouchStart: (() => void) | undefined;
|
||||
|
||||
Reference in New Issue
Block a user