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([
448448 if ( this . options . animate ) {
449449 this . _animate ( showProps ) ;
450450 } else {
451+ this . _scrollToTopIfVisible ( this . content . get ( 0 ) . parentElement ) ;
451452 this . content . show ( ) ;
452453 }
453454 this . _open ( ) ;
@@ -553,6 +554,27 @@ define([
553554 } , 1 ) ;
554555 } ) ;
555556 }
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 ;
556578 }
557579 } ) ;
558580
You can’t perform that action at this time.
0 commit comments