File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,6 +230,24 @@ $.extend( $.mobile, {
230230 this . loading . _widget = loader ;
231231
232232 return returnValue ;
233+ } ,
234+
235+ isElementCurrentlyVisible : function ( el ) {
236+ el = typeof el === "string" ? $ ( el ) [ 0 ] : el [ 0 ] ;
237+
238+ if ( ! el ) {
239+ return true ;
240+ }
241+
242+ var rect = el . getBoundingClientRect ( ) ;
243+
244+ return (
245+ rect . bottom > 0 &&
246+ rect . right > 0 &&
247+ rect . top <
248+ ( window . innerHeight || document . documentElement . clientHeight ) &&
249+ rect . left <
250+ ( window . innerWidth || document . documentElement . clientWidth ) ) ;
233251 }
234252} ) ;
235253
Original file line number Diff line number Diff line change @@ -216,7 +216,8 @@ return $.widget( "mobile.panel", {
216216 ( heightWithMargins - heightWithoutMargins ) ) ;
217217 }
218218 }
219- if ( scrollToTop === true ) {
219+ if ( scrollToTop === true &&
220+ ! $ . mobile . isElementCurrentlyVisible ( ".ui-content" ) ) {
220221 this . window [ 0 ] . scrollTo ( 0 , $ . mobile . defaultHomeScroll ) ;
221222 }
222223 } else {
You can’t perform that action at this time.
0 commit comments