Skip to content

Commit 38f0a0b

Browse files
committed
fix: handle animation cancel and stepIndex change during animation
1 parent 1de9918 commit 38f0a0b

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/ui-persistent-bottomsheet/index.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ export class PersistentBottomSheet extends GridLayout {
109109
private _isScrollEnabled = true;
110110
private scrollViewAtTop: boolean = true;
111111

112+
private animation: Animation;
113+
112114
constructor() {
113115
super();
114116
this.isPassThroughParentEnabled = true;
@@ -522,6 +524,9 @@ export class PersistentBottomSheet extends GridLayout {
522524

523525
animating = false;
524526
private async animateToPosition(position, duration = OPEN_DURATION) {
527+
if (this.animation) {
528+
this.animation.cancel();
529+
}
525530
if (this.animating) {
526531
return;
527532
}
@@ -562,18 +567,22 @@ export class PersistentBottomSheet extends GridLayout {
562567
})
563568
.filter((a) => !!a);
564569
try {
565-
await new Animation(params).play();
570+
this.animation = new Animation(params);
571+
await this.animation.play();
566572
} catch (err) {
573+
//ensure we go to end position
574+
this.applyTrData(trData);
567575
console.error('BottomSheet animation cancelled', err);
568576
} finally {
569577
this.isScrollEnabled = true;
570578
this.animating = false;
571-
if (position !== 0) {
572-
} else {
573-
// if (this.backDrop) {
574-
// this.backDrop.visibility = 'hidden';
575-
// }
576-
}
579+
this.animation = null;
580+
// if (position !== 0) {
581+
// } else {
582+
// // if (this.backDrop) {
583+
// // this.backDrop.visibility = 'hidden';
584+
// // }
585+
// }
577586
}
578587
}
579588
}

0 commit comments

Comments
 (0)