File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -109,18 +109,28 @@ function useSetupAnimatedValues<T>() {
109109 const containerMinusActiveCell =
110110 containerSize . value - activeCellSize . value + scrollOffset . value ;
111111
112+ const offsetRelativeToScrollTop =
113+ touchPositionDiff . value + activeCellOffset . value ;
112114 const constrained = Math . min (
113115 containerMinusActiveCell ,
114- Math . max (
115- scrollOffset . value ,
116- touchPositionDiff . value + activeCellOffset . value
117- )
116+ Math . max ( scrollOffset . value , offsetRelativeToScrollTop )
118117 ) ;
118+
119+ const maxTranslateNegative = - activeCellOffset . value ;
120+ const maxTranslatePositive =
121+ scrollViewSize . value - ( activeCellOffset . value + activeCellSize . value ) ;
122+
119123 // Only constrain the touch position while the finger is on the screen. This allows the active cell
120124 // to snap above/below the fold once let go, if the drag ends at the top/bottom of the screen.
121- return isTouchActiveNative . value
125+ const constrainedBase = isTouchActiveNative . value
122126 ? constrained - activeCellOffset . value
123127 : touchPositionDiff . value ;
128+
129+ // Make sure item is constrained to the boundaries of the scrollview
130+ return Math . min (
131+ Math . max ( constrainedBase , maxTranslateNegative ) ,
132+ maxTranslatePositive
133+ ) ;
124134 } , [ ] ) ;
125135
126136 const hoverAnim = useDerivedValue ( ( ) => {
You can’t perform that action at this time.
0 commit comments