@@ -432,7 +432,7 @@ ExecutionVisualizer.prototype.stepForward = function() {
432432 else {
433433 myViz . curInstr += 1 ;
434434 }
435- myViz . updateOutput ( ) ;
435+ myViz . updateOutput ( true ) ;
436436 return true ;
437437 }
438438
@@ -741,7 +741,8 @@ ExecutionVisualizer.prototype.renderPyCodeOutput = function() {
741741
742742
743743// This function is called every time the display needs to be updated
744- ExecutionVisualizer . prototype . updateOutput = function ( ) {
744+ // smoothTransition is OPTIONAL!
745+ ExecutionVisualizer . prototype . updateOutput = function ( smoothTransition ) {
745746 assert ( this . curTrace ) ;
746747
747748 var myViz = this ; // to prevent confusion of 'this' inside of nested functions
@@ -905,24 +906,47 @@ ExecutionVisualizer.prototype.updateOutput = function() {
905906 }
906907
907908 if ( prevLineNumber ) {
908- gutterSVG . find ( '#prevLineArrow' ) . show ( ) ;
909+ var pla = myViz . domRootD3 . select ( '#prevLineArrow' ) ;
910+ var translatePrevCmd = 'translate(0, ' + ( ( ( prevLineNumber - 1 ) * myViz . codeRowHeight ) + myViz . arrowOffsetY + prevVerticalNudge ) + ')' ;
911+
912+ if ( smoothTransition ) {
913+ pla
914+ . transition ( )
915+ . duration ( 200 )
916+ . attr ( 'fill' , 'white' )
917+ . each ( 'end' , function ( ) {
918+ pla
919+ . attr ( 'transform' , translatePrevCmd )
920+ . attr ( 'fill' , lightArrowColor ) ;
921+
922+ } ) ;
923+ }
924+ else {
925+ pla . attr ( 'transform' , translatePrevCmd )
926+ }
909927
910- myViz . domRootD3 . select ( '#prevLineArrow' )
911- . transition ( )
912- . duration ( 300 )
913- . attr ( 'transform' , 'translate(0, ' + ( ( ( prevLineNumber - 1 ) * myViz . codeRowHeight ) + myViz . arrowOffsetY + prevVerticalNudge ) + ')' ) ;
928+ gutterSVG . find ( '#prevLineArrow' ) . show ( ) ;
914929 }
915930 else {
916931 gutterSVG . find ( '#prevLineArrow' ) . hide ( ) ;
917932 }
918933
919934 if ( curLineNumber ) {
920- gutterSVG . find ( '#curLineArrow' ) . show ( ) ;
935+ var cla = myViz . domRootD3 . select ( '#curLineArrow' ) ;
936+ var translateCurCmd = 'translate(0, ' + ( ( ( curLineNumber - 1 ) * myViz . codeRowHeight ) + myViz . arrowOffsetY + curVerticalNudge ) + ')' ;
921937
922- myViz . domRootD3 . select ( '#curLineArrow' )
923- . transition ( )
924- . duration ( 300 )
925- . attr ( 'transform' , 'translate(0, ' + ( ( ( curLineNumber - 1 ) * myViz . codeRowHeight ) + myViz . arrowOffsetY + curVerticalNudge ) + ')' ) ;
938+ if ( smoothTransition ) {
939+ cla
940+ . transition ( )
941+ . delay ( 200 )
942+ . duration ( 300 )
943+ . attr ( 'transform' , translateCurCmd ) ;
944+ }
945+ else {
946+ cla . attr ( 'transform' , translateCurCmd ) ;
947+ }
948+
949+ gutterSVG . find ( '#curLineArrow' ) . show ( ) ;
926950 }
927951 else {
928952 gutterSVG . find ( '#curLineArrow' ) . hide ( ) ;
0 commit comments