@@ -4,12 +4,15 @@ import raf from 'rc-util/lib/raf';
4
4
5
5
const MIN_SIZE = 20 ;
6
6
7
+ export type ScrollBarDirectionType = 'ltr' | 'rtl' ;
8
+
7
9
export interface ScrollBarProps {
8
10
prefixCls : string ;
9
11
scrollTop : number ;
10
12
scrollHeight : number ;
11
13
height : number ;
12
14
count : number ;
15
+ direction ?: ScrollBarDirectionType ;
13
16
onScroll : ( scrollTop : number ) => void ;
14
17
onStartMove : ( ) => void ;
15
18
onStopMove : ( ) => void ;
@@ -90,7 +93,7 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
90
93
window . removeEventListener ( 'mouseup' , this . onMouseUp ) ;
91
94
92
95
this . scrollbarRef . current ?. removeEventListener ( 'touchstart' , this . onScrollbarTouchStart ) ;
93
-
96
+
94
97
if ( this . thumbRef . current ) {
95
98
this . thumbRef . current . removeEventListener ( 'touchstart' , this . onMouseDown ) ;
96
99
this . thumbRef . current . removeEventListener ( 'touchmove' , this . onMouseMove ) ;
@@ -185,12 +188,20 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
185
188
// ====================== Render =======================
186
189
render ( ) {
187
190
const { dragging, visible } = this . state ;
188
- const { prefixCls } = this . props ;
191
+ const { prefixCls, direction } = this . props ;
189
192
const spinHeight = this . getSpinHeight ( ) ;
190
193
const top = this . getTop ( ) ;
191
194
192
195
const canScroll = this . showScroll ( ) ;
193
196
const mergedVisible = canScroll && visible ;
197
+ const scrollBarDirection =
198
+ direction === 'rtl'
199
+ ? {
200
+ left : 0 ,
201
+ }
202
+ : {
203
+ right : 0 ,
204
+ } ;
194
205
195
206
return (
196
207
< div
@@ -202,7 +213,7 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
202
213
width : 8 ,
203
214
top : 0 ,
204
215
bottom : 0 ,
205
- right : 0 ,
216
+ ... scrollBarDirection ,
206
217
position : 'absolute' ,
207
218
display : mergedVisible ? null : 'none' ,
208
219
} }
0 commit comments