mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 13:32:54 +08:00
fix(animation): improve menu and go back swipe
This commit is contained in:
@ -65,7 +65,7 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
super(config, elementRef, renderer);
|
||||
|
||||
this._sbEnabled = config.getBoolean('swipeBackEnabled');
|
||||
this._sbThreshold = config.getNumber('swipeBackThreshold', 40);
|
||||
this._sbThreshold = config.getNumber('swipeBackThreshold', 0);
|
||||
|
||||
this.id = 'n' + (++ctrlIds);
|
||||
}
|
||||
@ -918,10 +918,11 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
}
|
||||
}
|
||||
|
||||
swipeBackEnd(shouldComplete: boolean, currentStepValue: number) {
|
||||
swipeBackEnd(shouldComplete: boolean, currentStepValue: number, velocity: number) {
|
||||
if (this._sbTrns && this._sbGesture) {
|
||||
// the swipe back gesture has ended
|
||||
this._sbTrns.progressEnd(shouldComplete, currentStepValue, 300);
|
||||
const dur = this._sbTrns.getDuration() / (Math.abs(velocity) + 1);
|
||||
this._sbTrns.progressEnd(shouldComplete, currentStepValue, dur);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,12 +53,13 @@ export class SwipeBackGesture extends SlideEdgeGesture {
|
||||
}
|
||||
|
||||
onSlideEnd(slide: SlideData, ev: any) {
|
||||
const velocity = slide.velocity;
|
||||
const currentStepValue = (slide.distance / slide.max);
|
||||
const isResetDirecction = slide.velocity < 0;
|
||||
const isResetDirecction = velocity < 0;
|
||||
const isMovingFast = Math.abs(slide.velocity) > 0.4;
|
||||
const isInResetZone = Math.abs(slide.delta) < Math.abs(slide.max) * 0.5;
|
||||
const shouldComplete = !swipeShouldReset(isResetDirecction, isMovingFast, isInResetZone);
|
||||
|
||||
this._nav.swipeBackEnd(shouldComplete, currentStepValue);
|
||||
this._nav.swipeBackEnd(shouldComplete, currentStepValue, velocity);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user