Commit c767e2e0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix-headers-blocking-anchors' into 'master'

Prevent anchors from being hidden by header upon a new page load

Browsers change the scroll position after the page is loaded, and the current 1 ms
delay wasn't long enough for the browser to jump to the anchor. Even then, it appears
another 100ms delay is necessary to adjust the scroll properly:

http://stackoverflow.com/questions/19057731/scrolltop-on-page-reload-doesnt-work-possible-script-conflict

Add a little more of an offset to see a few lines before the anchor.

* Closes #1614
* Closes #1024

See merge request !1225
parents e334ec06 1fdf56c9
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.0.0 (unreleased) v 8.0.0 (unreleased)
- Prevent anchors from being hidden by header (Stan Hu)
- Upgrade gitlab_git to 7.2.15 to fix `git blame` errors with ISO-encoded files (Stan Hu) - Upgrade gitlab_git to 7.2.15 to fix `git blame` errors with ISO-encoded files (Stan Hu)
- Prevent too many redirects upon login when home page URL is set to external_url (Stan Hu) - Prevent too many redirects upon login when home page URL is set to external_url (Stan Hu)
- Improve dropdown positioning on the project home page (Hannes Rosenögger) - Improve dropdown positioning on the project home page (Hannes Rosenögger)
......
...@@ -94,16 +94,18 @@ window.unbindEvents = -> ...@@ -94,16 +94,18 @@ window.unbindEvents = ->
$(document).off('scroll') $(document).off('scroll')
window.shiftWindow = -> window.shiftWindow = ->
scrollBy 0, -50 scrollBy 0, -100
document.addEventListener("page:fetch", unbindEvents) document.addEventListener("page:fetch", unbindEvents)
# Scroll the window to avoid the topnav bar
# https://github.com/twitter/bootstrap/issues/1768
if location.hash
setTimeout shiftWindow, 1
window.addEventListener "hashchange", shiftWindow window.addEventListener "hashchange", shiftWindow
window.onload = ->
# Scroll the window to avoid the topnav bar
# https://github.com/twitter/bootstrap/issues/1768
if location.hash
setTimeout shiftWindow, 100
$ -> $ ->
$(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF") $(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment