From 2d080ca835c7668bf317d6632bd0f49916a402d6 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Thu, 20 Jan 2022 10:40:54 +0000 Subject: [PATCH] [FIX] website: make animation works when cookies bar opened Before this commit, since [1], when the cookies bar is opened, the pages' animations would not work at all. Animated images would not even be shown, remaining invisible. This is because the s_popup when not using the layout 'popup' is still using the modal/popup snippet structure but is not really a modal anymore. As BS provide a built-in way to know if there is an open modal, which works well with the cookies bar, use it instead. [1]: https://github.com/odoo/design-themes/commit/e025296ccf5b8d8ea19bd354d9fbd52a12fc4d94 opw-2712755 (detected during migration) closes odoo/odoo#83291 X-original-commit: 48bb9efee99d3bee2b4b60eec0f59ed2cb13a096 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Romain Derie (rde) --- .../website/static/src/js/content/snippets.animation.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index a5805458bbd..20d667e3f66 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -1274,8 +1274,12 @@ registry.WebsiteAnimate = publicWidget.Widget.extend({ // We need to offset for the change in position from some animation. // So we get the top value by not taking CSS transforms into calculations. - const $openModal = this.$target.find('.modal:visible'); - const scrollTop = $openModal.length ? $openModal.scrollTop() : this.$scrollingElement.scrollTop(); + // Cookies bar might be opened and considered as a modal but it is + // not really one (eg 'discrete' layout), and should not be used as + // scrollTop value. + const scrollTop = document.body.classList.contains("modal-open") ? + this.$target.find('.modal:visible').scrollTop() : + this.$scrollingElement.scrollTop(); const elTop = this._getElementOffsetTop($el[0]) - scrollTop; const visible = this.windowsHeight > (elTop + elOffset) && 0 < (elTop + elHeight - elOffset);