From 28f472a66b00971964c1ab1c75289b68ea700f3f Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 13 Sep 2017 17:32:04 +0200 Subject: [PATCH] Fix initial visibility of header menu overflow controls in Safari --- .../WoltLabSuite/Core/Ui/Page/Header/Menu.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Menu.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Menu.js index 6878e26ea4..7dafc2d7fc 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Menu.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Menu.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @module WoltLabSuite/Core/Ui/Page/Header/Menu */ -define(['Ui/Screen'], function(UiScreen) { +define(['Environment', 'Ui/Screen'], function(Environment, UiScreen) { "use strict"; var _enabled = false; @@ -46,10 +46,22 @@ define(['Ui/Screen'], function(UiScreen) { _enable: function () { _enabled = true; - this._rebuildVisibility(); - - // IE11 sometimes suffers from a timing issue - window.setTimeout(this._rebuildVisibility.bind(this), 1000); + // Safari waits three seconds for a font to be loaded which causes the header menu items + // to be extremely wide while waiting for the font to be loaded. The extremely wide menu + // items in turn can cause the overflow controls to be shown even if the width of the header + // menu, after the font has been loaded successfully, does not require them. This width + // issue results in the next button being shown for a short time. To circumvent this issue, + // we wait a second before showing the obverflow controls in Safari. + // see https://webkit.org/blog/6643/improved-font-loading/ + if (Environment.browser() === 'safari') { + window.setTimeout(this._rebuildVisibility.bind(this), 1000); + } + else { + this._rebuildVisibility(); + + // IE11 sometimes suffers from a timing issue + window.setTimeout(this._rebuildVisibility.bind(this), 1000); + } }, /** -- 2.20.1