From 931fb8f80ca88623d422173d6c96e5a38c114650 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 14 Nov 2018 14:00:59 +0000 Subject: [FIX] website: recompute auto more menu on window full load The previous code made sure we wait for images to be fully loaded before initializing the auto more menu. But in some cases, it is not enough, we also have to wait for fonts or even extra scripts. Those will have no impact on the feature in most cases though, so we will only update the auto more menu at that time, not wait for it to initialize the feature. closes odoo/odoo#28684 --- addons/website/static/src/js/content/menu.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'addons/website/static/src/js/content') diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js index c5371e3c5fb..42a12414557 100644 --- a/addons/website/static/src/js/content/menu.js +++ b/addons/website/static/src/js/content/menu.js @@ -98,6 +98,17 @@ sAnimation.registry.autohideMenu = sAnimation.Class.extend({ def.resolve(); }); }); + + // The previous code will make sure we wait for images to be fully + // loaded before initializing the auto more menu. But in some cases, + // it is not enough, we also have to wait for fonts or even extra + // scripts. Those will have no impact on the feature in most cases + // though, so we will only update the auto more menu at that time, + // no wait for it to initialize the feature. + var $window = $(window); + $window.on('load.autohideMenu', function () { + $window.trigger('resize'); + }); } return $.when.apply($, defs).then(function () { if (!self.noAutohide) { @@ -112,6 +123,7 @@ sAnimation.registry.autohideMenu = sAnimation.Class.extend({ destroy: function () { this._super.apply(this, arguments); if (!this.noAutohide) { + $(window).off('.autohideMenu'); dom.destroyAutoMoreMenu(this.$el); } }, -- cgit v1.2.3