Skip to content

Commit d17ac78

Browse files
author
Philip Guo
committed
added simple animation for left gutter arrows
1 parent b8c6700 commit d17ac78

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

‎v3/js/pytutor.js‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -681,18 +681,18 @@ ExecutionVisualizer.prototype.renderPyCodeOutput = function() {
681681
myViz.domRoot.find('#pyCodeOutput tr:first')
682682
.prepend('<td id="gutterTD" valign="top" rowspan="' + this.codeOutputLines.length + '"><svg id="leftCodeGutterSVG"/></td>');
683683

684-
// create prevLineArrow and curLineArrow, but don't fill them in with colors just yet ...
684+
// create prevLineArrow and curLineArrow
685685
myViz.domRootD3.select('svg#leftCodeGutterSVG')
686686
.append('polygon')
687687
.attr('id', 'prevLineArrow')
688688
.attr('points', SVG_ARROW_POLYGON)
689-
.attr('fill', 'white');
689+
.attr('fill', lightArrowColor);
690690

691691
myViz.domRootD3.select('svg#leftCodeGutterSVG')
692692
.append('polygon')
693693
.attr('id', 'curLineArrow')
694694
.attr('points', SVG_ARROW_POLYGON)
695-
.attr('fill', 'white');
695+
.attr('fill', darkArrowColor);
696696

697697

698698
// 2012-09-05: Disable breakpoints for now to simplify UX
@@ -786,8 +786,6 @@ ExecutionVisualizer.prototype.updateOutput = function() {
786786
myViz.arrowOffsetY = Math.floor((myViz.codeRowHeight / 2) - (SVG_ARROW_HEIGHT / 2)) - teenyAdjustment;
787787

788788
myViz.leftGutterSvgInitialized = true;
789-
790-
console.log(myViz.codeRowHeight);
791789
}
792790

793791
assert(myViz.arrowOffsetY !== undefined);
@@ -907,19 +905,23 @@ ExecutionVisualizer.prototype.updateOutput = function() {
907905
}
908906

909907
if (prevLineNumber) {
910-
gutterSVG.find('#prevLineArrow')
911-
.show()
912-
.attr('fill', lightArrowColor)
908+
gutterSVG.find('#prevLineArrow').show();
909+
910+
myViz.domRootD3.select('#prevLineArrow')
911+
.transition()
912+
.duration(300)
913913
.attr('transform', 'translate(0, ' + (((prevLineNumber - 1) * myViz.codeRowHeight) + myViz.arrowOffsetY + prevVerticalNudge) + ')');
914914
}
915915
else {
916916
gutterSVG.find('#prevLineArrow').hide();
917917
}
918918

919919
if (curLineNumber) {
920-
gutterSVG.find('#curLineArrow')
921-
.show()
922-
.attr('fill', darkArrowColor)
920+
gutterSVG.find('#curLineArrow').show();
921+
922+
myViz.domRootD3.select('#curLineArrow')
923+
.transition()
924+
.duration(300)
923925
.attr('transform', 'translate(0, ' + (((curLineNumber - 1) * myViz.codeRowHeight) + myViz.arrowOffsetY + curVerticalNudge) + ')');
924926
}
925927
else {

0 commit comments

Comments
 (0)