Avoid early layout trashing
authorAlexander Ebert <ebert@woltlab.com>
Wed, 15 Nov 2017 12:23:11 +0000 (13:23 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 15 Nov 2017 12:23:11 +0000 (13:23 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js

index 8caf25c8bfbda23f3d888e4617947b6ef15ad90d..7a70c8b6e81347f80af540eb0ee37819c01342c1 100644 (file)
@@ -70,8 +70,6 @@ define(
                        UiDialog.setup();
                        UiTooltip.setup();
                        
-                       new UiPageJumpToTop();
-                       
                        // convert method=get into method=post
                        var forms = elBySelAll('form[method=get]');
                        for (var i = 0, length = forms.length; i < length; i++) {
@@ -84,12 +82,18 @@ define(
                                };
                        }
                        
-                       // DEBUG ONLY
                        var interval = 0;
                        interval = window.setInterval(function() {
                                if (typeof window.jQuery === 'function') {
                                        window.clearInterval(interval);
                                        
+                                       // the 'jump to top' button triggers style recalculation/layout,
+                                       // putting it at the end of the jQuery queue avoids trashing the
+                                       // layout too early and thus delaying the page initialization
+                                       window.jQuery(function() {
+                                               new UiPageJumpToTop();
+                                       });
+                                       
                                        window.jQuery.holdReady(false);
                                }
                        }, 20);