From 37c05ff02399a8f8ec23a16de6c4d456968276b3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 13 May 2013 19:49:14 +0200 Subject: [PATCH] Improved initial jump to an anchor --- wcfsetup/install/files/js/WCF.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 852ff9bea7..5285678ded 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -5508,13 +5508,23 @@ WCF.System.JumpToAnchor = { if (window.location.hash) { var $element = $(window.location.hash); if ($element.length) { - $element.addClass('userPanelJumpToAnchorFix'); - - new WCF.PeriodicalExecuter(function(pe) { - pe.stop(); + if ($.browser.chrome || $.browser.msie) { + $element.addClass('userPanelJumpToAnchorFix'); - $element.removeClass('userPanelJumpToAnchorFix'); - }, 5000); + $(document).on('readystatechange', function() { + if (document.readyState === 'complete') { + // wait 100ms + new WCF.PeriodicalExecuter(function(pe) { + pe.stop(); + + $element.removeClass('userPanelJumpToAnchorFix'); + }, 100); + } + }); + } + else { + window.scrollBy(0, -1 * $('.userPanel').outerHeight()); + } } } } -- 2.20.1