File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -448,6 +448,7 @@ define([
448
448
if ( this . options . animate ) {
449
449
this . _animate ( showProps ) ;
450
450
} else {
451
+ this . _scrollToTopIfVisible ( this . content . get ( 0 ) . parentElement ) ;
451
452
this . content . show ( ) ;
452
453
}
453
454
this . _open ( ) ;
@@ -553,6 +554,27 @@ define([
553
554
} , 1 ) ;
554
555
} ) ;
555
556
}
557
+ } ,
558
+
559
+ /**
560
+ * @param {HTMLElement } elem
561
+ * @private
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
+ */
574
+ _isElementOutOfViewport : function ( elem ) {
575
+ var rect = elem . getBoundingClientRect ( ) ;
576
+
577
+ return rect . bottom < 0 || rect . right < 0 || rect . left > window . innerWidth || rect . top > window . innerHeight ;
556
578
}
557
579
} ) ;
558
580
You can’t perform that action at this time.
0 commit comments