mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
When going back a page, scroll to the last known vertical position
This is only needed for JS-enhanced links. Without javascript to mess it up, the browser handles this 100% correctly by itself.
This commit is contained in:
parent
203bd5070c
commit
075b8f67fe
@ -145,3 +145,22 @@ function characterCount()
|
||||
{
|
||||
return $("#id_status").val().length + $("#id_spoiler_text").val().length;
|
||||
}
|
||||
|
||||
function savePlace()
|
||||
{
|
||||
sessionStorage.setItem("lastScrollPos", window.scrollY);
|
||||
return true;
|
||||
}
|
||||
|
||||
function restorePlace(ev)
|
||||
{
|
||||
var lastScrollPos = sessionStorage.getItem('lastScrollPos');
|
||||
Intercooler.ready(function (elt)
|
||||
{
|
||||
if (elt[0].tagName == 'BODY')
|
||||
{
|
||||
window.scrollTo(0, lastScrollPos);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
@ -40,7 +40,8 @@
|
||||
{% endif %}
|
||||
</head>
|
||||
<body class="has-navbar-fixed-top" ic-history-elt="true"
|
||||
ic-global-include='{"csrfmiddlewaretoken": "{{ csrf_token }}"}'>
|
||||
ic-global-include='{"csrfmiddlewaretoken": "{{ csrf_token }}"}'
|
||||
ic-on-beforeSend="savePlace()">
|
||||
<div id="page-load-indicator"> </div>
|
||||
{% block navbar %}
|
||||
<nav class="navbar is-fixed-top" role="navigation"
|
||||
@ -199,6 +200,8 @@
|
||||
|
||||
<script type="application/javascript">
|
||||
document.addEventListener('DOMContentLoaded', menuPrepare);
|
||||
$(document).on('handle.onpopstate.ic',
|
||||
restorePlace);
|
||||
</script>
|
||||
{% block page_scripts_inline %}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user