summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/website/static/src/js/content/menu.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js
index c0b82c58a21..c2959c40fcb 100644
--- a/addons/website/static/src/js/content/menu.js
+++ b/addons/website/static/src/js/content/menu.js
@@ -97,12 +97,23 @@ const BaseAnimatedHeader = animations.Animation.extend({
this._transitionCount += addCount;
this._transitionCount = Math.max(0, this._transitionCount);
- // The normal case would be to have the transitionend event to be
- // fired but we cannot rely on it, so we use a timeout as fallback.
- clearTimeout(this._paddingLoopTimer);
+ // As long as we detected a transition start without its related
+ // transition end, keep updating the main padding top.
if (this._transitionCount > 0) {
window.requestAnimationFrame(() => this._updateMainPaddingTopLoop());
- this._paddingLoopTimer = setTimeout(() => this._updateMainPaddingTopLoop(-1), 500);
+
+ // The normal case would be to have the transitionend event to be
+ // fired but we cannot rely on it, so we use a timeout as fallback.
+ if (addCount !== 0) {
+ clearTimeout(this._paddingLoopTimer);
+ this._paddingLoopTimer = setTimeout(() => {
+ this._updateMainPaddingTopLoop(-this._transitionCount);
+ }, 500);
+ }
+ } else {
+ // When we detected all transitionend events, we need to stop the
+ // setTimeout fallback.
+ clearTimeout(this._paddingLoopTimer);
}
},