mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
refactor(gestures): move to constants from enum
move to constants from enum
This commit is contained in:
@ -17,24 +17,22 @@ export const GESTURE_REFRESHER = 'refresher';
|
||||
/** @private */
|
||||
export const GESTURE_TOGGLE = 'toggle';
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export const enum GesturePriority {
|
||||
Minimun = -10000,
|
||||
VeryLow = -20,
|
||||
Low = -10,
|
||||
Normal = 0,
|
||||
High = 10,
|
||||
VeryHigh = 20,
|
||||
VeryVeryHigh = 30,
|
||||
|
||||
SlidingItem = Low,
|
||||
MenuSwipe = High,
|
||||
GoBackSwipe = VeryHigh,
|
||||
Refresher = Normal,
|
||||
Toggle = VeryVeryHigh
|
||||
}
|
||||
/** @private */
|
||||
export const GESTURE_PRIORITY_SLIDING_ITEM = -10;
|
||||
|
||||
/** @private */
|
||||
export const GESTURE_PRIORITY_REFRESHER = 0;
|
||||
|
||||
/** @private */
|
||||
export const GESTURE_PRIORITY_MENU_SWIPE = 10;
|
||||
|
||||
/** @private */
|
||||
export const GESTURE_PRIORITY_GO_BACK_SWIPE = 20;
|
||||
|
||||
/** @private */
|
||||
export const GESTURE_PRIORITY_TOGGLE = 30;
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
@ -112,7 +110,7 @@ export class GestureController {
|
||||
return false;
|
||||
}
|
||||
let requestedStart = this.requestedStart;
|
||||
let maxPriority = GesturePriority.Minimun;
|
||||
let maxPriority = -10000;
|
||||
for (let gestureID in requestedStart) {
|
||||
maxPriority = Math.max(maxPriority, requestedStart[gestureID]);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export class PointerEvents {
|
||||
private lastTouchEvent: number = 0;
|
||||
|
||||
mouseWait: number = 2 * 1000;
|
||||
lastEventType: PointerEventType = PointerEventType.UNDEFINED;
|
||||
lastEventType: number;
|
||||
|
||||
constructor(
|
||||
private plt: Platform,
|
||||
@ -45,8 +45,8 @@ export class PointerEvents {
|
||||
assert(this.pointerDown, 'pointerDown can not be null');
|
||||
|
||||
this.lastTouchEvent = Date.now() + this.mouseWait;
|
||||
this.lastEventType = PointerEventType.TOUCH;
|
||||
if (!this.pointerDown(ev, PointerEventType.TOUCH)) {
|
||||
this.lastEventType = POINTER_EVENT_TYPE_TOUCH;
|
||||
if (!this.pointerDown(ev, POINTER_EVENT_TYPE_TOUCH)) {
|
||||
return;
|
||||
}
|
||||
if (!this.rmTouchMove && this.pointerMove) {
|
||||
@ -68,8 +68,8 @@ export class PointerEvents {
|
||||
console.debug('mousedown event dropped because of previous touch');
|
||||
return;
|
||||
}
|
||||
this.lastEventType = PointerEventType.MOUSE;
|
||||
if (!this.pointerDown(ev, PointerEventType.MOUSE)) {
|
||||
this.lastEventType = POINTER_EVENT_TYPE_MOUSE;
|
||||
if (!this.pointerDown(ev, POINTER_EVENT_TYPE_MOUSE)) {
|
||||
return;
|
||||
}
|
||||
if (!this.rmMouseMove && this.pointerMove) {
|
||||
@ -82,12 +82,12 @@ export class PointerEvents {
|
||||
|
||||
private handleTouchEnd(ev: any) {
|
||||
this.stopTouch();
|
||||
this.pointerUp && this.pointerUp(ev, PointerEventType.TOUCH);
|
||||
this.pointerUp && this.pointerUp(ev, POINTER_EVENT_TYPE_TOUCH);
|
||||
}
|
||||
|
||||
private handleMouseUp(ev: any) {
|
||||
this.stopMouse();
|
||||
this.pointerUp && this.pointerUp(ev, PointerEventType.MOUSE);
|
||||
this.pointerUp && this.pointerUp(ev, POINTER_EVENT_TYPE_MOUSE);
|
||||
}
|
||||
|
||||
private stopTouch() {
|
||||
@ -120,11 +120,9 @@ export class PointerEvents {
|
||||
}
|
||||
|
||||
|
||||
export const enum PointerEventType {
|
||||
UNDEFINED,
|
||||
MOUSE,
|
||||
TOUCH
|
||||
}
|
||||
export const POINTER_EVENT_TYPE_MOUSE = 1;
|
||||
export const POINTER_EVENT_TYPE_TOUCH = 2;
|
||||
|
||||
|
||||
export interface PointerEventsConfig {
|
||||
element?: HTMLElement;
|
||||
|
Reference in New Issue
Block a user