Skip to content

Commit 9f53931

Browse files
author
Philip Guo
committed
added a heightChangeCallback optional parameter to ExecutionVisualizer,
which is a function to call whenever the HEIGHT of #dataViz changes
1 parent 27f1606 commit 9f53931

2 files changed

Lines changed: 42 additions & 28 deletions

File tree

v3/embedding-demo.js

Lines changed: 29 additions & 28 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
7676
// updateOutputCallback - function to call (with 'this' as parameter)
7777
// whenever this.updateOutput() is called
7878
// (BEFORE rendering the output display)
79+
// heightChangeCallback - function to call (with 'this' as parameter)
80+
// whenever the HEIGHT of #dataViz changes
7981
// verticalStack - if true, then stack code display ON TOP of visualization
8082
// (else place side-by-side)
8183
function ExecutionVisualizer(domRootID, dat, params) {
@@ -773,6 +775,8 @@ ExecutionVisualizer.prototype.updateOutput = function(smoothTransition) {
773775
return;
774776
}
775777

778+
var prevDataVizHeight = myViz.domRoot.find('#dataViz').height();
779+
776780

777781
var gutterSVG = myViz.domRoot.find('svg#leftCodeGutterSVG');
778782

@@ -1048,6 +1052,15 @@ ExecutionVisualizer.prototype.updateOutput = function(smoothTransition) {
10481052

10491053
// finally, render all of the data structures
10501054
this.renderDataStructures();
1055+
1056+
1057+
// call the callback if necessary (BEFORE rendering)
1058+
if (this.params.heightChangeCallback) {
1059+
if (myViz.domRoot.find('#dataViz').height() != prevDataVizHeight) {
1060+
this.params.heightChangeCallback(this);
1061+
}
1062+
}
1063+
10511064
}
10521065

10531066

0 commit comments

Comments
 (0)