@@ -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,18 +75,29 @@ 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
+ if ( direction === "ltr" ) {
79
+ if ( left <= 0 ) {
80
+ left = 0 ;
81
+ }
82
+ if ( left + scrollBarWidth >= bodyWidth ) {
83
+ left = bodyWidth - scrollBarWidth ;
84
+ }
85
+ onScroll ( {
86
+ scrollLeft : left / bodyWidth * ( bodyScrollWidth + 2 )
87
+ } ) ;
88
+ refState . current . x = event . pageX ;
89
+ } else {
90
+ if ( left > 0 ) {
91
+ left = 0 ;
92
+ }
93
+ if ( Math . abs ( left ) + Math . abs ( scrollBarWidth ) < bodyWidth ) {
94
+ onScroll ( {
95
+ scrollLeft : left / bodyWidth * ( bodyScrollWidth + 2 )
96
+ } ) ;
97
+ refState . current . x = event . pageX ;
98
+ }
83
99
}
84
100
85
- onScroll ( {
86
- scrollLeft : ( left / bodyWidth ) * ( bodyScrollWidth + 2 ) ,
87
- } ) ;
88
-
89
101
refState . current . x = event . pageX ;
90
102
} ;
91
103
0 commit comments