Skip to content

Commit 74aa9d8

Browse files
authored
fix(panel): fix panel close routine if it was closed immediately (#4127)
fixes #4108 (again) In practice, the time until the transition start is variable depending on the browser, amongst other things. Android + Chrome is between 27 => 44ms with a fast phone, but can take longer under many circumstances. This removes the hardcoded time and instead looks for the transition start.
1 parent c9115b2 commit 74aa9d8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/core/components/panel/panel-class.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class Panel extends Framework7Class {
289289
onOpen(modifyHtmlClasses = true) {
290290
const panel = this;
291291
// eslint-disable-next-line
292-
panel._openTimeStamp = new Date().getTime();
292+
panel._openTransitionStarted = false;
293293
const app = panel.app;
294294

295295
panel.opened = true;
@@ -442,6 +442,13 @@ class Panel extends Framework7Class {
442442
}
443443
const transitionEndTarget = effect === 'reveal' ? $viewEl : $el;
444444

445+
function panelTransitionStart() {
446+
transitionEndTarget.transitionStart(() => {
447+
// eslint-disable-next-line
448+
panel._openTransitionStarted = true;
449+
});
450+
}
451+
445452
function panelTransitionEnd() {
446453
transitionEndTarget.transitionEnd((e) => {
447454
if ($(e.target).is(transitionEndTarget)) {
@@ -457,6 +464,7 @@ class Panel extends Framework7Class {
457464
if ($backdropEl) {
458465
$backdropEl.removeClass('not-animated');
459466
}
467+
panelTransitionStart();
460468
panelTransitionEnd();
461469
$el.removeClass('panel-out not-animated').addClass('panel-in');
462470
panel.onOpen();
@@ -488,8 +496,7 @@ class Panel extends Framework7Class {
488496
}
489497
const transitionEndTarget = effect === 'reveal' ? $viewEl : $el;
490498
// eslint-disable-next-line
491-
const openTimeDiff = new Date().getTime() - panel._openTimeStamp;
492-
if (openTimeDiff < 16) {
499+
if (!panel._openTransitionStarted) {
493500
// eslint-disable-next-line
494501
animate = false;
495502
}

0 commit comments

Comments
 (0)