@@ -1232,6 +1232,10 @@ var VirtualRenderer = function(container, theme) {
12321232
12331233 var topMargin = $viewMargin && $viewMargin . top || 0 ;
12341234 var bottomMargin = $viewMargin && $viewMargin . bottom || 0 ;
1235+
1236+ if ( this . $scrollAnimation ) {
1237+ this . $stopAnimation = true ;
1238+ }
12351239
12361240 var scrollTop = this . $scrollAnimation ? this . session . getScrollTop ( ) : this . scrollTop ;
12371241
@@ -1378,7 +1382,20 @@ var VirtualRenderer = function(container, theme) {
13781382 _self . session . setScrollTop ( steps . shift ( ) ) ;
13791383 // trick session to think it's already scrolled to not loose toValue
13801384 _self . session . $scrollTop = toValue ;
1385+
1386+ function endAnimation ( ) {
1387+ _self . $timer = clearInterval ( _self . $timer ) ;
1388+ _self . $scrollAnimation = null ;
1389+ _self . $stopAnimation = false ;
1390+ callback && callback ( ) ;
1391+ }
1392+
13811393 this . $timer = setInterval ( function ( ) {
1394+ if ( _self . $stopAnimation ) {
1395+ endAnimation ( ) ;
1396+ return ;
1397+ }
1398+
13821399 if ( ! _self . session )
13831400 return clearInterval ( _self . $timer ) ;
13841401 if ( steps . length ) {
@@ -1390,9 +1407,7 @@ var VirtualRenderer = function(container, theme) {
13901407 toValue = null ;
13911408 } else {
13921409 // do this on separate step to not get spurious scroll event from scrollbar
1393- _self . $timer = clearInterval ( _self . $timer ) ;
1394- _self . $scrollAnimation = null ;
1395- callback && callback ( ) ;
1410+ endAnimation ( ) ;
13961411 }
13971412 } , 10 ) ;
13981413 } ;
0 commit comments