File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -448,9 +448,7 @@ define([
448
448
if ( this . options . animate ) {
449
449
this . _animate ( showProps ) ;
450
450
} else {
451
- if ( this . _isElementOutOfViewport ( this . content . get ( 0 ) . parentElement ) ) {
452
- this . content . get ( 0 ) . parentElement . scrollIntoView ( ) ;
453
- }
451
+ this . _scrollToTopIfVisible ( this . content . get ( 0 ) . parentElement ) ;
454
452
this . content . show ( ) ;
455
453
}
456
454
this . _open ( ) ;
@@ -562,8 +560,20 @@ define([
562
560
* @param {HTMLElement } elem
563
561
* @private
564
562
*/
563
+ _scrollToTopIfVisible : function ( elem ) {
564
+ if ( this . _isElementOutOfViewport ( elem ) ) {
565
+ elem . scrollIntoView ( ) ;
566
+ }
567
+ } ,
568
+
569
+ /**
570
+ * @param {HTMLElement } elem
571
+ * @private
572
+ * @return {Boolean }
573
+ */
565
574
_isElementOutOfViewport : function ( elem ) {
566
575
var rect = elem . getBoundingClientRect ( ) ;
576
+
567
577
return rect . bottom < 0 || rect . right < 0 || rect . left > window . innerWidth || rect . top > window . innerHeight ;
568
578
}
569
579
} ) ;
You can’t perform that action at this time.
0 commit comments