Skip to content

Commit 20c4c72

Browse files
committed
🛠 use unload event over beforeunload
1 parent 29c59a8 commit 20c4c72

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎js/history.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ proto.createHistoryAppend = function() {
7676
this.scrollPageIndex = 0;
7777
// events
7878
this.scrollHistoryHandler = this.onScrollHistory.bind( this );
79-
this.beforeunloadHandler = this.onBeforeunload.bind( this );
79+
this.unloadHandler = this.onUnload.bind( this );
8080
this.scroller.addEventListener( 'scroll', this.scrollHistoryHandler );
8181
this.on( 'append', this.onAppendHistory );
8282
this.bindHistoryAppendEvents( true );
@@ -85,7 +85,7 @@ proto.createHistoryAppend = function() {
8585
proto.bindHistoryAppendEvents = function( isBind ) {
8686
var addRemove = isBind ? 'addEventListener' : 'removeEventListener';
8787
this.scroller[ addRemove ]( 'scroll', this.scrollHistoryHandler );
88-
window[ addRemove ]( 'beforeunload', this.beforeunloadHandler );
88+
window[ addRemove ]( 'unload', this.unloadHandler );
8989
};
9090

9191
proto.createHistoryPageLoad = function() {
@@ -180,7 +180,7 @@ proto.setHistory = function( title, path ) {
180180

181181
// scroll to top to prevent initial scroll-reset after page refresh
182182
// http://stackoverflow.com/a/18633915/182183
183-
proto.onBeforeunload = function() {
183+
proto.onUnload = function() {
184184
var pageIndex = this.scrollPageIndex;
185185
if ( pageIndex === 0 ) {
186186
return;

0 commit comments

Comments
 (0)