@@ -70,10 +70,10 @@ export const getClientScroll = (
7070 } = prevScrollState ;
7171
7272 nextScrollState . isScrollingLeft = isScrollingLeft ( x , nextScrollState ) ;
73- nextScrollState . isScrollingRight = ! nextScrollState . isScrollingLeft ;
73+ nextScrollState . isScrollingRight = isScrollingRight ( x , nextScrollState ) ;
7474
7575 nextScrollState . isScrollingUp = isScrollingUp ( y , nextScrollState ) ;
76- nextScrollState . isScrollingDown = ! nextScrollState . isScrollingUp ;
76+ nextScrollState . isScrollingDown = isScrollingDown ( y , nextScrollState ) ;
7777
7878 nextScrollState . xTurn =
7979 nextScrollState . isScrollingLeft === prevIsScrollingLeft ? prevXTurn : x ;
@@ -102,6 +102,19 @@ const isScrollingLeft = (x: number, prev: IScroll) => {
102102 }
103103} ;
104104
105+ const isScrollingRight = ( x : number , prev : IScroll ) => {
106+ switch ( true ) {
107+ case x > prev . x :
108+ return true ;
109+ case x < prev . x :
110+ return false ;
111+ case x === prev . x :
112+ return prev . isScrollingRight ;
113+ default :
114+ throw new Error ( 'Could not calculate isScrollingRight' ) ;
115+ }
116+ } ;
117+
105118const isScrollingUp = ( y : number , prev : IScroll ) => {
106119 switch ( true ) {
107120 case y < prev . y :
@@ -111,7 +124,20 @@ const isScrollingUp = (y: number, prev: IScroll) => {
111124 case y === prev . y :
112125 return prev . isScrollingUp ;
113126 default :
114- throw new Error ( 'Could not calculate yDir' ) ;
127+ throw new Error ( 'Could not calculate isScrollingUp' ) ;
128+ }
129+ } ;
130+
131+ const isScrollingDown = ( y : number , prev : IScroll ) => {
132+ switch ( true ) {
133+ case y > prev . y :
134+ return true ;
135+ case y < prev . y :
136+ return false ;
137+ case y === prev . y :
138+ return prev . isScrollingDown ;
139+ default :
140+ throw new Error ( 'Could not calculate isScrollingDown' ) ;
115141 }
116142} ;
117143
0 commit comments