Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 9bbe152

Browse files
author
Gabriel Schulhof
committed
Popup: Record scrollTop upon open and close, and restore it upon hashchange. Fixes #5334.
1 parent 6103ba8 commit 9bbe152

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

js/widgets/popup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ define( [ "jquery",
203203

204204
// Define instance variables
205205
$.extend( this, {
206+
_scrollTop: 0,
206207
_page: thisPage,
207208
_ui: ui,
208209
_fallbackTransition: "",
@@ -701,6 +702,8 @@ define( [ "jquery",
701702
_closePopup: function( e, data ) {
702703
var parsedDst, toUrl;
703704

705+
window.scrollTo( 0, this._scrollTop );
706+
704707
if ( e.type === "pagebeforechange" && data ) {
705708
// Determine whether we need to rapid-close the popup, or whether we can
706709
// take the time to run the closing transition
@@ -746,6 +749,7 @@ define( [ "jquery",
746749

747750
// set the global popup mutex
748751
$.mobile.popup.active = this;
752+
this._scrollTop = $( window ).scrollTop();
749753

750754
// if history alteration is disabled close on navigate events
751755
// and leave the url as is
@@ -812,6 +816,8 @@ define( [ "jquery",
812816
return;
813817
}
814818

819+
this._scrollTop = $( window ).scrollTop();
820+
815821
if( this.options.history ) {
816822
$.mobile.back();
817823
} else {

0 commit comments

Comments
 (0)