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

Commit e219bea

Browse files
committed
Panel: ScrollTop only when ui-content is out of view
Fixes #6767 Closes #8483
1 parent 2f00774 commit e219bea

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

js/helpers.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,19 @@ $.extend( $.mobile, {
255255
this.loading._widget = loader;
256256

257257
return returnValue;
258+
},
259+
260+
isElementCurrentlyVisible: function( el ) {
261+
el = typeof el === "string" ? $( el )[ 0 ] : el[ 0 ];
262+
var rect = el.getBoundingClientRect();
263+
264+
return (
265+
rect.bottom > 0 &&
266+
rect.right > 0 &&
267+
rect.top <
268+
( window.innerHeight || document.documentElement.clientHeight ) &&
269+
rect.left <
270+
( window.innerWidth || document.documentElement.clientWidth ) );
258271
}
259272
} );
260273

js/widgets/panel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)