[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) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Romain Derie
2022-01-25 15:41:07 +00:00
parent 5dd9610145
commit 2d080ca835
@@ -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);