@@ -12,11 +12,12 @@ interface StickyScrollBarProps {
1212 scrollBodyRef : React . RefObject < HTMLDivElement > ;
1313 onScroll : ( params : { scrollLeft ?: number } ) => void ;
1414 offsetScroll : number ;
15- container : HTMLElement | Window ;
15+ container : HTMLElement | Window ,
16+ direction : string ;
1617}
1718
1819const StickyScrollBar : React . ForwardRefRenderFunction < unknown , StickyScrollBarProps > = (
19- { scrollBodyRef, onScroll, offsetScroll, container } ,
20+ { scrollBodyRef, onScroll, offsetScroll, container, direction } ,
2021 ref ,
2122) => {
2223 const prefixCls = useContext ( TableContext , 'prefixCls' ) ;
@@ -74,19 +75,21 @@ const StickyScrollBar: React.ForwardRefRenderFunction<unknown, StickyScrollBarPr
7475 let left : number =
7576 refState . current . x + event . pageX - refState . current . x - refState . current . delta ;
7677
77- if ( left <= 0 ) {
78- left = 0 ;
79- }
80-
81- if ( left + scrollBarWidth >= bodyWidth ) {
82- left = bodyWidth - scrollBarWidth ;
78+ const isLTR = direction === "ltr" ;
79+ // Limit scroll range
80+ left = Math . max (
81+ isLTR ? 0 : - bodyWidth + scrollBarWidth ,
82+ Math . min ( isLTR ? bodyWidth - scrollBarWidth : 0 , left )
83+ ) ;
84+ // Calculate the scroll position and update
85+ const shouldScroll =
86+ isLTR || Math . abs ( left ) + Math . abs ( scrollBarWidth ) < bodyWidth ;
87+ if ( shouldScroll ) {
88+ onScroll ( {
89+ scrollLeft : ( left / bodyWidth ) * ( bodyScrollWidth + 2 ) ,
90+ } ) ;
91+ refState . current . x = event . pageX ;
8392 }
84-
85- onScroll ( {
86- scrollLeft : ( left / bodyWidth ) * ( bodyScrollWidth + 2 ) ,
87- } ) ;
88-
89- refState . current . x = event . pageX ;
9093 } ;
9194
9295 const checkScrollBarVisible = ( ) => {
0 commit comments