mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
@@ -29,8 +29,8 @@ export class GestureController {
|
||||
*/
|
||||
createBlocker(opts: BlockerConfig = {}): BlockerDelegate {
|
||||
return new BlockerDelegate(
|
||||
this.newID(),
|
||||
this,
|
||||
this.newID(),
|
||||
opts.disable,
|
||||
!!opts.disableScroll
|
||||
);
|
||||
@@ -95,10 +95,16 @@ export class GestureController {
|
||||
|
||||
disableScroll(id: number) {
|
||||
this.disabledScroll.add(id);
|
||||
if (this.disabledScroll.size === 1) {
|
||||
this.doc.body.classList.add(BACKDROP_NO_SCROLL);
|
||||
}
|
||||
}
|
||||
|
||||
enableScroll(id: number) {
|
||||
this.disabledScroll.delete(id);
|
||||
if (this.disabledScroll.size === 0) {
|
||||
this.doc.body.classList.remove(BACKDROP_NO_SCROLL);
|
||||
}
|
||||
}
|
||||
|
||||
canStart(gestureName: string): boolean {
|
||||
@@ -140,7 +146,7 @@ export class GestureDelegate {
|
||||
private ctrl?: GestureController;
|
||||
|
||||
constructor(
|
||||
ctrl: any,
|
||||
ctrl: GestureController,
|
||||
private id: number,
|
||||
private name: string,
|
||||
private priority: number,
|
||||
@@ -199,8 +205,8 @@ export class BlockerDelegate {
|
||||
private ctrl?: GestureController;
|
||||
|
||||
constructor(
|
||||
ctrl: GestureController,
|
||||
private id: number,
|
||||
ctrl: any,
|
||||
private disable: string[] | undefined,
|
||||
private disableScroll: boolean
|
||||
) {
|
||||
@@ -253,4 +259,5 @@ export interface BlockerConfig {
|
||||
disableScroll?: boolean;
|
||||
}
|
||||
|
||||
export const gestureController = new GestureController(document);
|
||||
const BACKDROP_NO_SCROLL = 'backdrop-no-scroll';
|
||||
export const GESTURE_CONTROLLER = new GestureController(document);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { QueueApi } from '@stencil/core';
|
||||
|
||||
import { gestureController } from './gesture-controller';
|
||||
import { GESTURE_CONTROLLER } from './gesture-controller';
|
||||
import { createPointerEvents } from './pointer-events';
|
||||
import { createPanRecognizer } from './recognizers';
|
||||
|
||||
@@ -52,7 +52,7 @@ export function createGesture(config: GestureConfig): Gesture {
|
||||
);
|
||||
|
||||
const pan = createPanRecognizer(finalConfig.direction, finalConfig.threshold, finalConfig.maxAngle);
|
||||
const gesture = gestureController.createGesture({
|
||||
const gesture = GESTURE_CONTROLLER.createGesture({
|
||||
name: config.gestureName,
|
||||
priority: config.gesturePriority,
|
||||
disableScroll: config.disableScroll
|
||||
|
||||
Reference in New Issue
Block a user