@@ -698,7 +698,7 @@ const Buffer = Module("buffer", {
698
698
* Scrolls to the bottom of the current buffer.
699
699
*/
700
700
scrollBottom : function ( ) {
701
- Buffer . scrollToPercent ( null , 100 ) ;
701
+ Buffer . scrollElemToPercent ( null , null , 100 ) ;
702
702
} ,
703
703
704
704
/**
@@ -715,7 +715,7 @@ const Buffer = Module("buffer", {
715
715
* Scrolls to the top of the current buffer.
716
716
*/
717
717
scrollEnd : function ( ) {
718
- Buffer . scrollToPercent ( 100 , null ) ;
718
+ Buffer . scrollElemToPercent ( null , 100 , null ) ;
719
719
} ,
720
720
721
721
/**
@@ -772,7 +772,7 @@ const Buffer = Module("buffer", {
772
772
* @param {number } y The vertical page percentile.
773
773
*/
774
774
scrollToPercent : function ( x , y ) {
775
- Buffer . scrollToPercent ( x , y ) ;
775
+ Buffer . scrollElemToPercent ( null , x , y ) ;
776
776
} ,
777
777
778
778
/**
@@ -790,14 +790,14 @@ const Buffer = Module("buffer", {
790
790
* Scrolls the current buffer laterally to its leftmost.
791
791
*/
792
792
scrollStart : function ( ) {
793
- Buffer . scrollToPercent ( 0 , null ) ;
793
+ Buffer . scrollElemToPercent ( null , 0 , null ) ;
794
794
} ,
795
795
796
796
/**
797
797
* Scrolls the current buffer vertically to the top.
798
798
*/
799
799
scrollTop : function ( ) {
800
- Buffer . scrollToPercent ( null , 0 ) ;
800
+ Buffer . scrollElemToPercent ( null , null , 0 ) ;
801
801
} ,
802
802
803
803
// TODO: allow callback for filtering out unwanted frames? User defined?
@@ -1064,7 +1064,7 @@ const Buffer = Module("buffer", {
1064
1064
return win ;
1065
1065
} ,
1066
1066
1067
- findScrollable : function findScrollable ( dir , horizontal ) {
1067
+ findScrollable : function findScrollable ( dir = 0 , horizontal ) {
1068
1068
let pos = "scrollTop ", maxPos = "scrollTopMax ", clientSize = "clientHeight ";
1069
1069
if ( horizontal )
1070
1070
pos = "scrollLeft ", maxPos = "scrollLeftMax ", clientSize = "clientWidth ";
@@ -1076,7 +1076,7 @@ const Buffer = Module("buffer", {
1076
1076
for ( ; elem && elem . parentNode instanceof Element ; elem = elem . parentNode ) {
1077
1077
if ( elem [ clientSize ] == 0 )
1078
1078
continue ;
1079
- if ( dir < 0 && elem [ pos ] > 0 || dir > 0 && elem [ pos ] < elem [ maxPos ] )
1079
+ if ( dir < 0 && elem [ pos ] > 0 || dir > 0 && elem [ pos ] < elem [ maxPos ] || dir == 0 && elem [ maxPos ] > 0 )
1080
1080
break ;
1081
1081
}
1082
1082
return elem ;
0 commit comments