mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
fix(menu): fix swipe gesture
This commit is contained in:
@ -85,7 +85,7 @@ export class Gesture {
|
||||
return;
|
||||
}
|
||||
if (this.pan || this.hasPress) {
|
||||
Context.enableListener(this, 'touchstart', isEnabled);
|
||||
Context.enableListener(this, 'touchstart', isEnabled, this.attachTo);
|
||||
Context.enableListener(this, 'mousedown', isEnabled, this.attachTo);
|
||||
if (!isEnabled) {
|
||||
this.abortGesture();
|
||||
@ -124,7 +124,6 @@ export class Gesture {
|
||||
|
||||
if (this.lastTouch === 0 || (this.lastTouch + MOUSE_WAIT < timeStamp)) {
|
||||
if (this.pointerDown(ev, timeStamp)) {
|
||||
console.log('hola');
|
||||
this.enableMouse(true);
|
||||
this.enableTouch(false);
|
||||
} else {
|
||||
|
||||
@ -323,9 +323,13 @@ export class Menu {
|
||||
}
|
||||
|
||||
// const isRTL = false;
|
||||
const isRightSide = this.isRightSide;
|
||||
const z = this._width;
|
||||
let delta = slide.deltaX;
|
||||
delta = Math.max((isRightSide) ? -delta : delta);
|
||||
|
||||
// const z = (this.isRightSide !== isRTL ? slide.min : slide.max);
|
||||
const stepValue = (Math.abs(slide.deltaX) / z);
|
||||
const stepValue = delta / z;
|
||||
|
||||
this._animation.progressStep(stepValue);
|
||||
// TODO: this.ionDrag.emit({ menu: this });
|
||||
@ -337,8 +341,11 @@ export class Menu {
|
||||
assert(false, '_isAnimating has to be true');
|
||||
return;
|
||||
}
|
||||
const isRightSide = this.isRightSide;
|
||||
let delta = slide.deltaX;
|
||||
delta = Math.max((isRightSide) ? -delta : delta);
|
||||
|
||||
const width = this._width;
|
||||
const delta = Math.abs(slide.deltaX)
|
||||
const stepValue = delta / width;
|
||||
const velocity = slide.velocityX;
|
||||
const z = width / 2;
|
||||
@ -348,7 +355,6 @@ export class Menu {
|
||||
const shouldCompleteLeft = (velocity <= 0)
|
||||
&& (velocity < -0.2 || slide.deltaX < -z);
|
||||
|
||||
const isRightSide = this.isRightSide;
|
||||
const opening = !this._isOpen;
|
||||
const shouldComplete = (opening)
|
||||
? isRightSide ? shouldCompleteLeft : shouldCompleteRight
|
||||
@ -361,8 +367,11 @@ export class Menu {
|
||||
|
||||
const missing = shouldComplete ? 1 - stepValue : stepValue;
|
||||
const missingDistance = missing * width;
|
||||
const dur = missingDistance / Math.abs(velocity);
|
||||
const realDur = Math.min(dur, 380);
|
||||
let realDur = 0;
|
||||
if (missingDistance > 5) {
|
||||
const dur = missingDistance / Math.abs(velocity);
|
||||
realDur = Math.min(dur, 380);
|
||||
}
|
||||
|
||||
this._animation
|
||||
.onFinish(() => this._after(isOpen), { clearExistingCallacks: true })
|
||||
|
||||
Reference in New Issue
Block a user