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); } },