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