Skip to content

Commit 7ed4150

Browse files
author
Philip Guo
committed
added an redrawAllConnectorsOnHeightChange option
1 parent 7f96c8d commit 7ed4150

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

v3/embedding-demo.js

Lines changed: 4 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v3/js/pytutor.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5555
5656
*/
5757

58+
var allVisualizers = []; // global array of ALL visualizers ever on the page
59+
5860

5961
var SVG_ARROW_POLYGON = '0,3 12,3 12,0 18,5 12,10 12,7 0,7';
6062
var SVG_ARROW_HEIGHT = 10; // must match height of SVG_ARROW_POLYGON
@@ -78,6 +80,9 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
7880
// (BEFORE rendering the output display)
7981
// heightChangeCallback - function to call (with 'this' as parameter)
8082
// whenever the HEIGHT of #dataViz changes
83+
// redrawAllConnectorsOnHeightChange - if this is non-null, then call redrawConnectors() in ALL ExecutionVisualizer
84+
// objects on this page whenever the height of ANY of them changes.
85+
// (NB: This might be inefficient and overkill; use at your own discretion.)
8186
// verticalStack - if true, then stack code display ON TOP of visualization
8287
// (else place side-by-side)
8388
function ExecutionVisualizer(domRootID, dat, params) {
@@ -158,6 +163,8 @@ function ExecutionVisualizer(domRootID, dat, params) {
158163
this.hasRendered = false;
159164

160165
this.render(); // go for it!
166+
167+
allVisualizers.push(this);
161168
}
162169

163170

@@ -1062,10 +1069,16 @@ ExecutionVisualizer.prototype.updateOutput = function(smoothTransition) {
10621069

10631070

10641071
// call the callback if necessary (BEFORE rendering)
1065-
if (this.params.heightChangeCallback) {
1066-
if (myViz.domRoot.find('#dataViz').height() != prevDataVizHeight) {
1072+
if (myViz.domRoot.find('#dataViz').height() != prevDataVizHeight) {
1073+
if (this.params.heightChangeCallback) {
10671074
this.params.heightChangeCallback(this);
10681075
}
1076+
1077+
if (this.params.redrawAllConnectorsOnHeightChange) {
1078+
$.each(allVisualizers, function(i, e) {
1079+
e.redrawConnectors();
1080+
});
1081+
}
10691082
}
10701083

10711084
}

0 commit comments

Comments
 (0)