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

Commit b243436

Browse files
author
Gabriel Schulhof
committed
Popup: Record scrollTop upon open and close, and restore it upon hashchange. Fixes #5334.
1 parent 7e8ea36 commit b243436

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
@@ -188,6 +188,7 @@ define( [ "jquery",
188188

189189
// Define instance variables
190190
$.extend( this, {
191+
_scrollTop: 0,
191192
_page: thisPage,
192193
_ui: ui,
193194
_fallbackTransition: "",
@@ -708,6 +709,8 @@ define( [ "jquery",
708709
_closePopup: function( e, data ) {
709710
var parsedDst, toUrl;
710711

712+
window.scrollTo( 0, this._scrollTop );
713+
711714
if ( e.type === "pagebeforechange" && data ) {
712715
// Determine whether we need to rapid-close the popup, or whether we can
713716
// take the time to run the closing transition
@@ -755,6 +758,7 @@ define( [ "jquery",
755758

756759
// set the global popup mutex
757760
$.mobile.popup.active = this;
761+
this._scrollTop = $( window ).scrollTop();
758762

759763
// if history alteration is disabled close on navigate events
760764
// and leave the url as is
@@ -821,6 +825,8 @@ define( [ "jquery",
821825
return;
822826
}
823827

828+
this._scrollTop = $( window ).scrollTop();
829+
824830
if( this.options.history ) {
825831
$.mobile.back();
826832
} else {

0 commit comments

Comments
 (0)