Commit bfca70a 1 parent 12cfc81 commit bfca70a Copy full SHA for bfca70a
File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,13 @@ const findCurrentPageIndex = (wrapper: HTMLDivElement): number => {
20
20
return - 1 ;
21
21
} ;
22
22
23
- const isAtEnd = ( ) => window . innerWidth + window . scrollX >= document . body . scrollWidth ;
23
+ const SCROLL_SAFE_ZONE = 5 ; // px
24
+ const isAtEnd = ( ) => {
25
+ const visibleEnd = window . innerWidth + window . scrollX ;
26
+ // SCROLL_SAFE_ZONE is here for special cases when window might be .5px shorter
27
+ // and math just dont add up correctly
28
+ return visibleEnd >= document . body . scrollWidth - SCROLL_SAFE_ZONE ;
29
+ } ;
24
30
const isAtStart = ( ) => window . scrollX <= 0 ;
25
31
26
32
export default function HorizontalPager ( props : IReaderProps ) {
Original file line number Diff line number Diff line change @@ -21,10 +21,16 @@ const findCurrentPageIndex = (wrapper: HTMLDivElement): number => {
21
21
} ;
22
22
23
23
// TODO: make configurable?
24
+ const SCROLL_SAFE_ZONE = 5 ; // px
24
25
const SCROLL_OFFSET = 0.95 ;
25
26
const SCROLL_BEHAVIOR : ScrollBehavior = 'smooth' ;
26
27
27
- const isAtBottom = ( ) => window . innerHeight + window . scrollY >= document . body . offsetHeight ;
28
+ const isAtBottom = ( ) => {
29
+ const visibleBottom = window . innerHeight + window . scrollY ;
30
+ // SCROLL_SAFE_ZONE is here for special cases when window might be .5px shorter
31
+ // and math just dont add up correctly
32
+ return visibleBottom >= document . body . offsetHeight - SCROLL_SAFE_ZONE ;
33
+ } ;
28
34
const isAtTop = ( ) => window . scrollY <= 0 ;
29
35
30
36
export default function VerticalPager ( props : IReaderProps ) {
You can’t perform that action at this time.
0 commit comments