summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2016-12-12 12:30:55 -0600
committerMike Greiling <mike@pixelcog.com>2016-12-28 09:57:40 -0600
commitda44d84da07fbacb6f2e27dbf619860f0010f711 (patch)
tree469c622ad81e8881bfda451390b50ceeb015b45a
parent6892216f5f65687d4dc53e7e08c649e858fa8ff4 (diff)
downloadgitlab-ce-da44d84da07fbacb6f2e27dbf619860f0010f711.tar.gz
catch instances where hashchange event is not fired yet we still want to adjust scroll position
-rw-r--r--app/assets/javascripts/application.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 043c6a11c4f..302f108ce17 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -76,6 +76,14 @@
gl.utils.handleLocationHash();
}, false);
+ // `hashchange` is not triggered when link target is already in window.location
+ $('body').on('click', 'a', function() {
+ var href = this.getAttribute('href');
+ if (href.indexOf('#') === 0 && href.substr(1) === gl.utils.getLocationHash()) {
+ setTimeout(gl.utils.handleLocationHash, 1);
+ }
+ });
+
$(function () {
var $body = $('body');
var $document = $(document);