Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrollToHash failing on links #376

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion grip/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
<div class="page">
{% block page %}{% endblock %}
</div>
{%- block scripts %}{% endblock %}
{%- block scripts %}{% endblock -%}
<script>
function scrollToHash() {
if (location.hash && !document.querySelector(":target")) {
var elements = document.getElementsByName('user-content-' + location.hash.slice(1));
if (elements.length > 0) {
elements[elements.length - 1].scrollIntoView();
}
}
}
</script>
</body>
</html>
9 changes: 0 additions & 9 deletions grip/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@
}
}

function scrollToHash() {
if (location.hash && !document.querySelector(':target')) {
var element = document.getElementById('user-content-' + location.hash.slice(1));
if (element) {
element.scrollIntoView();
}
}
}

function autorefreshContent(eventSourceUrl) {
var initialTitle = document.title;
var contentElement = document.getElementById('grip-content');
Expand Down
8 changes: 0 additions & 8 deletions grip/templates/limit.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@

{%- block scripts -%}
<script>
function scrollToHash() {
if (location.hash && !document.querySelector(":target")) {
var elements = document.getElementsByName('user-content-' + location.hash.slice(1));
if (elements.length > 0) {
elements[elements.length - 1].scrollIntoView();
}
}
}
window.onhashchange = function() {
scrollToHash();
}
Expand Down