@@ -71,7 +71,7 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
71
71
e . preventDefault ( ) ;
72
72
} ;
73
73
74
- onContainerMouseDown : React . MouseEventHandler = e => {
74
+ onContainerMouseDown : React . MouseEventHandler = ( e ) => {
75
75
e . stopPropagation ( ) ;
76
76
e . preventDefault ( ) ;
77
77
} ;
@@ -173,38 +173,35 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
173
173
return ptg * enableHeightRange ;
174
174
} ;
175
175
176
- // Not show scrollbar when height is large thane scrollHeight
177
- getVisible = ( ) : boolean => {
178
- const { visible } = this . state ;
176
+ // Not show scrollbar when height is large than scrollHeight
177
+ showScroll = ( ) : boolean => {
179
178
const { height, scrollHeight } = this . props ;
180
-
181
- if ( height >= scrollHeight ) {
182
- return false ;
183
- }
184
-
185
- return visible ;
179
+ return scrollHeight > height ;
186
180
} ;
187
181
188
182
// ====================== Render =======================
189
183
render ( ) {
190
- const { dragging } = this . state ;
184
+ const { dragging, visible } = this . state ;
191
185
const { prefixCls } = this . props ;
192
186
const spinHeight = this . getSpinHeight ( ) ;
193
187
const top = this . getTop ( ) ;
194
188
195
- const visible = this . getVisible ( ) ;
189
+ const canScroll = this . showScroll ( ) ;
190
+ const mergedVisible = canScroll && visible ;
196
191
197
192
return (
198
193
< div
199
194
ref = { this . scrollbarRef }
200
- className = { `${ prefixCls } -scrollbar` }
195
+ className = { classNames ( `${ prefixCls } -scrollbar` , {
196
+ [ `${ prefixCls } -scrollbar-show` ] : canScroll ,
197
+ } ) }
201
198
style = { {
202
199
width : 8 ,
203
200
top : 0 ,
204
201
bottom : 0 ,
205
202
right : 0 ,
206
203
position : 'absolute' ,
207
- display : visible ? null : 'none' ,
204
+ display : mergedVisible ? null : 'none' ,
208
205
} }
209
206
onMouseDown = { this . onContainerMouseDown }
210
207
onMouseMove = { this . delayHidden }
0 commit comments