Skip to content

Commit

Permalink
[FIX] website: recompute auto more menu on window full load
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
qsm-odoo committed Nov 14, 2018
1 parent 09fde26 commit bb1dd33
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addons/website/static/src/js/content/menu.js
Expand Up @@ -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) {
Expand All @@ -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);
}
},
Expand Down

0 comments on commit bb1dd33

Please sign in to comment.