@@ -71,7 +71,7 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
7171 e . preventDefault ( ) ;
7272 } ;
7373
74- onContainerMouseDown : React . MouseEventHandler = e => {
74+ onContainerMouseDown : React . MouseEventHandler = ( e ) => {
7575 e . stopPropagation ( ) ;
7676 e . preventDefault ( ) ;
7777 } ;
@@ -173,38 +173,35 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
173173 return ptg * enableHeightRange ;
174174 } ;
175175
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 => {
179178 const { height, scrollHeight } = this . props ;
180-
181- if ( height >= scrollHeight ) {
182- return false ;
183- }
184-
185- return visible ;
179+ return scrollHeight > height ;
186180 } ;
187181
188182 // ====================== Render =======================
189183 render ( ) {
190- const { dragging } = this . state ;
184+ const { dragging, visible } = this . state ;
191185 const { prefixCls } = this . props ;
192186 const spinHeight = this . getSpinHeight ( ) ;
193187 const top = this . getTop ( ) ;
194188
195- const visible = this . getVisible ( ) ;
189+ const canScroll = this . showScroll ( ) ;
190+ const mergedVisible = canScroll && visible ;
196191
197192 return (
198193 < div
199194 ref = { this . scrollbarRef }
200- className = { `${ prefixCls } -scrollbar` }
195+ className = { classNames ( `${ prefixCls } -scrollbar` , {
196+ [ `${ prefixCls } -scrollbar-show` ] : canScroll ,
197+ } ) }
201198 style = { {
202199 width : 8 ,
203200 top : 0 ,
204201 bottom : 0 ,
205202 right : 0 ,
206203 position : 'absolute' ,
207- display : visible ? null : 'none' ,
204+ display : mergedVisible ? null : 'none' ,
208205 } }
209206 onMouseDown = { this . onContainerMouseDown }
210207 onMouseMove = { this . delayHidden }
0 commit comments