Skip to content
Open
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
6 changes: 3 additions & 3 deletions js/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ proto.createHistoryAppend = function() {
this.scrollPage = this.scrollPages[0];
// events
this.scrollHistoryHandler = this.onScrollHistory.bind( this );
this.unloadHandler = this.onUnload.bind( this );
this.pagehideHandler = this.onPagehide.bind( this );
this.scroller.addEventListener( 'scroll', this.scrollHistoryHandler );
this.on( 'append', this.onAppendHistory );
this.bindHistoryAppendEvents( true );
Expand All @@ -77,7 +77,7 @@ proto.createHistoryAppend = function() {
proto.bindHistoryAppendEvents = function( isBind ) {
let addRemove = isBind ? 'addEventListener' : 'removeEventListener';
this.scroller[ addRemove ]( 'scroll', this.scrollHistoryHandler );
window[ addRemove ]( 'unload', this.unloadHandler );
window[ addRemove ]( 'pagehide', this.pagehideHandler );
};

proto.createHistoryPageLoad = function() {
Expand Down Expand Up @@ -160,7 +160,7 @@ proto.setHistory = function( title, path ) {

// scroll to top to prevent initial scroll-reset after page refresh
// https://stackoverflow.com/a/18633915/182183
proto.onUnload = function() {
proto.onPagehide = function() {
if ( this.scrollPage.top === 0 ) return;

// calculate where scroll position would be on refresh
Expand Down