@@ -126,7 +126,7 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
126
126
const enableScrollRange = this . getEnableScrollRange ( ) ;
127
127
const enableHeightRange = this . getEnableHeightRange ( ) ;
128
128
129
- const ptg = newTop / enableHeightRange ;
129
+ const ptg = enableHeightRange ? newTop / enableHeightRange : 0 ;
130
130
const newScrollTop = Math . ceil ( ptg * enableScrollRange ) ;
131
131
this . moveRaf = raf ( ( ) => {
132
132
onScroll ( newScrollTop ) ;
@@ -153,19 +153,22 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
153
153
154
154
getEnableScrollRange = ( ) => {
155
155
const { scrollHeight, height } = this . props ;
156
- return scrollHeight - height ;
156
+ return scrollHeight - height || 0 ;
157
157
} ;
158
158
159
159
getEnableHeightRange = ( ) => {
160
160
const { height } = this . props ;
161
161
const spinHeight = this . getSpinHeight ( ) ;
162
- return height - spinHeight ;
162
+ return height - spinHeight || 0 ;
163
163
} ;
164
164
165
165
getTop = ( ) => {
166
166
const { scrollTop } = this . props ;
167
167
const enableScrollRange = this . getEnableScrollRange ( ) ;
168
168
const enableHeightRange = this . getEnableHeightRange ( ) ;
169
+ if ( scrollTop === 0 || enableScrollRange === 0 ) {
170
+ return 0 ;
171
+ }
169
172
const ptg = scrollTop / enableScrollRange ;
170
173
return ptg * enableHeightRange ;
171
174
} ;
0 commit comments