Permalink
Browse files

Popup: Record scrollTop upon open and close, and restore it upon hash…

…change. Fixes #5334.
  • Loading branch information...
1 parent 6103ba8 commit 9bbe152a8b923282698fa65b2a250df16ace6bcc @gabrielschulhof gabrielschulhof committed Nov 27, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 js/widgets/popup.js
View
@@ -203,6 +203,7 @@ define( [ "jquery",
// Define instance variables
$.extend( this, {
+ _scrollTop: 0,
_page: thisPage,
_ui: ui,
_fallbackTransition: "",
@@ -701,6 +702,8 @@ define( [ "jquery",
_closePopup: function( e, data ) {
var parsedDst, toUrl;
+ window.scrollTo( 0, this._scrollTop );
+
if ( e.type === "pagebeforechange" && data ) {
// Determine whether we need to rapid-close the popup, or whether we can
// take the time to run the closing transition
@@ -746,6 +749,7 @@ define( [ "jquery",
// set the global popup mutex
$.mobile.popup.active = this;
+ this._scrollTop = $( window ).scrollTop();
// if history alteration is disabled close on navigate events
// and leave the url as is
@@ -812,6 +816,8 @@ define( [ "jquery",
return;
}
+ this._scrollTop = $( window ).scrollTop();
+
if( this.options.history ) {
$.mobile.back();
} else {

0 comments on commit 9bbe152

Please sign in to comment.