@@ -12,11 +12,12 @@ interface StickyScrollBarProps {
12
12
scrollBodyRef : React . RefObject < HTMLDivElement > ;
13
13
onScroll : ( params : { scrollLeft ?: number } ) => void ;
14
14
offsetScroll : number ;
15
- container : HTMLElement | Window ;
15
+ container : HTMLElement | Window ,
16
+ direction : string ;
16
17
}
17
18
18
19
const StickyScrollBar : React . ForwardRefRenderFunction < unknown , StickyScrollBarProps > = (
19
- { scrollBodyRef, onScroll, offsetScroll, container } ,
20
+ { scrollBodyRef, onScroll, offsetScroll, container, direction } ,
20
21
ref ,
21
22
) => {
22
23
const prefixCls = useContext ( TableContext , 'prefixCls' ) ;
@@ -74,19 +75,21 @@ const StickyScrollBar: React.ForwardRefRenderFunction<unknown, StickyScrollBarPr
74
75
let left : number =
75
76
refState . current . x + event . pageX - refState . current . x - refState . current . delta ;
76
77
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 ;
83
92
}
84
-
85
- onScroll ( {
86
- scrollLeft : ( left / bodyWidth ) * ( bodyScrollWidth + 2 ) ,
87
- } ) ;
88
-
89
- refState . current . x = event . pageX ;
90
93
} ;
91
94
92
95
const checkScrollBarVisible = ( ) => {
0 commit comments