File tree 2 files changed +20
-1
lines changed 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,24 @@ $.extend( $.mobile, {
230
230
this . loading . _widget = loader ;
231
231
232
232
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 ) ) ;
233
251
}
234
252
} ) ;
235
253
Original file line number Diff line number Diff line change @@ -216,7 +216,8 @@ return $.widget( "mobile.panel", {
216
216
( heightWithMargins - heightWithoutMargins ) ) ;
217
217
}
218
218
}
219
- if ( scrollToTop === true ) {
219
+ if ( scrollToTop === true &&
220
+ ! $ . mobile . isElementCurrentlyVisible ( ".ui-content" ) ) {
220
221
this . window [ 0 ] . scrollTo ( 0 , $ . mobile . defaultHomeScroll ) ;
221
222
}
222
223
} else {
You can’t perform that action at this time.
0 commit comments