mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
nav: browser back navigation does not jump to the correct position #509
This commit is contained in:
parent
1c3ef135f0
commit
dc6524200d
2 changed files with 24 additions and 2 deletions
|
@ -26,6 +26,8 @@ This document shows you what's new in the latest release and flags it with one o
|
|||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme has updated its Mermaid dependency to 10.6.0. This adds support for [block diagrams](shortcodes/mermaid#block-diagram).
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} This release fixes a long outstanding bug where the page wasn't repositioning correctly when going forward or backward in your browser history.
|
||||
|
||||
---
|
||||
|
||||
## 5.25.0 (2024-02-29) {#5250}
|
||||
|
|
|
@ -1167,7 +1167,19 @@ function initScrollPositionSaver(){
|
|||
state.contentScrollTop = +elc.scrollTop;
|
||||
window.history.replaceState( state, '', window.location );
|
||||
};
|
||||
window.addEventListener( 'pagehide', savePosition );
|
||||
|
||||
var ticking = false;
|
||||
elc.addEventListener( 'scroll', function( event ){
|
||||
if( !ticking ){
|
||||
window.requestAnimationFrame( function(){
|
||||
savePosition();
|
||||
ticking = false;
|
||||
});
|
||||
ticking = true;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener( "click", savePosition );
|
||||
}
|
||||
|
||||
function scrollToPositions() {
|
||||
|
@ -1228,6 +1240,15 @@ function scrollToPositions() {
|
|||
}
|
||||
}
|
||||
|
||||
window.addEventListener( 'popstate', function ( event ){
|
||||
scrollToPositions();
|
||||
});
|
||||
|
||||
const observer = new PerformanceObserver( function(){
|
||||
scrollToPositions();
|
||||
});
|
||||
observer.observe({ type: "navigation" });
|
||||
|
||||
function mark() {
|
||||
// mark some additional stuff as searchable
|
||||
var bodyInnerLinks = document.querySelectorAll( '#R-body-inner a:not(.lightbox-link):not(.btn):not(.lightbox-back)' );
|
||||
|
@ -1525,7 +1546,6 @@ ready( function(){
|
|||
initImage();
|
||||
initExpand();
|
||||
initScrollPositionSaver();
|
||||
scrollToPositions();
|
||||
});
|
||||
|
||||
(function(){
|
||||
|
|
Loading…
Reference in a new issue