@@ -333,23 +333,39 @@ export default class SortableList extends Component {
333
333
this . _startAutoScroll ( {
334
334
direction : - 1 ,
335
335
shouldScroll : ( ) => this . _contentOffset . y > 0 ,
336
+ getScrollStep : ( stepIndex ) => {
337
+ const nextStep = this . _getScrollStep ( stepIndex ) ;
338
+
339
+ return this . _contentOffset . y - nextStep < 0
340
+ ? this . _contentOffset . y
341
+ : nextStep ;
342
+ } ,
336
343
} ) ;
337
344
} else if ( inAutoScrollDownArea ) {
338
345
this . _startAutoScroll ( {
339
346
direction : 1 ,
340
347
shouldScroll : ( ) => {
341
- const {
342
- contentHeight,
343
- containerLayout,
344
- } = this . state ;
348
+ const { contentHeight, containerLayout} = this . state ;
345
349
346
350
return this . _contentOffset . y < contentHeight - containerLayout . height ;
347
351
} ,
352
+ getScrollStep : ( stepIndex ) => {
353
+ const nextStep = this . _getScrollStep ( stepIndex ) ;
354
+ const { contentHeight, containerLayout} = this . state ;
355
+
356
+ return this . _contentOffset . y + nextStep > contentHeight - containerLayout . height
357
+ ? contentHeight - containerLayout . height - this . _contentOffset . y
358
+ : nextStep ;
359
+ } ,
348
360
} ) ;
349
361
}
350
362
}
351
363
352
- _startAutoScroll ( { direction, shouldScroll} ) {
364
+ _getScrollStep ( stepIndex ) {
365
+ return stepIndex > 3 ? 60 : 30 ;
366
+ }
367
+
368
+ _startAutoScroll ( { direction, shouldScroll, getScrollStep} ) {
353
369
if ( ! shouldScroll ( ) ) {
354
370
return ;
355
371
}
@@ -358,15 +374,8 @@ export default class SortableList extends Component {
358
374
let counter = 0 ;
359
375
360
376
this . _autoScrollInterval = setInterval ( ( ) => {
361
- counter ++ ;
362
377
if ( shouldScroll ( ) ) {
363
- let dy ;
364
- if ( counter > 3 ) {
365
- dy = 60 ;
366
- } else {
367
- dy = 30 ;
368
- }
369
- dy = direction * dy ;
378
+ const dy = direction * getScrollStep ( counter ++ ) ;
370
379
this . scrollBy ( { dy} ) ;
371
380
this . _rows [ activeRowKey ] . moveBy ( { dy} ) ;
372
381
} else {
0 commit comments