mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +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 */
|
/** @private */
|
||||||
export const GESTURE_TOGGLE = 'toggle';
|
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,
|
/** @private */
|
||||||
MenuSwipe = High,
|
export const GESTURE_PRIORITY_SLIDING_ITEM = -10;
|
||||||
GoBackSwipe = VeryHigh,
|
|
||||||
Refresher = Normal,
|
/** @private */
|
||||||
Toggle = VeryVeryHigh
|
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
|
* @private
|
||||||
@ -112,7 +110,7 @@ export class GestureController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let requestedStart = this.requestedStart;
|
let requestedStart = this.requestedStart;
|
||||||
let maxPriority = GesturePriority.Minimun;
|
let maxPriority = -10000;
|
||||||
for (let gestureID in requestedStart) {
|
for (let gestureID in requestedStart) {
|
||||||
maxPriority = Math.max(maxPriority, requestedStart[gestureID]);
|
maxPriority = Math.max(maxPriority, requestedStart[gestureID]);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ export class PointerEvents {
|
|||||||
private lastTouchEvent: number = 0;
|
private lastTouchEvent: number = 0;
|
||||||
|
|
||||||
mouseWait: number = 2 * 1000;
|
mouseWait: number = 2 * 1000;
|
||||||
lastEventType: PointerEventType = PointerEventType.UNDEFINED;
|
lastEventType: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private plt: Platform,
|
private plt: Platform,
|
||||||
@ -45,8 +45,8 @@ export class PointerEvents {
|
|||||||
assert(this.pointerDown, 'pointerDown can not be null');
|
assert(this.pointerDown, 'pointerDown can not be null');
|
||||||
|
|
||||||
this.lastTouchEvent = Date.now() + this.mouseWait;
|
this.lastTouchEvent = Date.now() + this.mouseWait;
|
||||||
this.lastEventType = PointerEventType.TOUCH;
|
this.lastEventType = POINTER_EVENT_TYPE_TOUCH;
|
||||||
if (!this.pointerDown(ev, PointerEventType.TOUCH)) {
|
if (!this.pointerDown(ev, POINTER_EVENT_TYPE_TOUCH)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.rmTouchMove && this.pointerMove) {
|
if (!this.rmTouchMove && this.pointerMove) {
|
||||||
@ -68,8 +68,8 @@ export class PointerEvents {
|
|||||||
console.debug('mousedown event dropped because of previous touch');
|
console.debug('mousedown event dropped because of previous touch');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.lastEventType = PointerEventType.MOUSE;
|
this.lastEventType = POINTER_EVENT_TYPE_MOUSE;
|
||||||
if (!this.pointerDown(ev, PointerEventType.MOUSE)) {
|
if (!this.pointerDown(ev, POINTER_EVENT_TYPE_MOUSE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.rmMouseMove && this.pointerMove) {
|
if (!this.rmMouseMove && this.pointerMove) {
|
||||||
@ -82,12 +82,12 @@ export class PointerEvents {
|
|||||||
|
|
||||||
private handleTouchEnd(ev: any) {
|
private handleTouchEnd(ev: any) {
|
||||||
this.stopTouch();
|
this.stopTouch();
|
||||||
this.pointerUp && this.pointerUp(ev, PointerEventType.TOUCH);
|
this.pointerUp && this.pointerUp(ev, POINTER_EVENT_TYPE_TOUCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleMouseUp(ev: any) {
|
private handleMouseUp(ev: any) {
|
||||||
this.stopMouse();
|
this.stopMouse();
|
||||||
this.pointerUp && this.pointerUp(ev, PointerEventType.MOUSE);
|
this.pointerUp && this.pointerUp(ev, POINTER_EVENT_TYPE_MOUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private stopTouch() {
|
private stopTouch() {
|
||||||
@ -120,11 +120,9 @@ export class PointerEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const enum PointerEventType {
|
export const POINTER_EVENT_TYPE_MOUSE = 1;
|
||||||
UNDEFINED,
|
export const POINTER_EVENT_TYPE_TOUCH = 2;
|
||||||
MOUSE,
|
|
||||||
TOUCH
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PointerEventsConfig {
|
export interface PointerEventsConfig {
|
||||||
element?: HTMLElement;
|
element?: HTMLElement;
|
||||||
|
Reference in New Issue
Block a user