Skip to content

Commit

Permalink
#285 fix recall function
Browse files Browse the repository at this point in the history
  • Loading branch information
wje7-cdc committed Oct 30, 2020
1 parent de63f9a commit 081221d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
25 changes: 11 additions & 14 deletions components/2d_network.html
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ <h5 class="modal-title">Export Network Image</h5>
});

session.network.nodes = newNodes;

let nodes = svg.select('g.nodes').selectAll('g').data(newNodes, d => d._id)
.join(
enter => {
Expand Down Expand Up @@ -1726,25 +1726,22 @@ <h5 class="modal-title">Export Network Image</h5>
.attr('pointer-events', d3.event.ctrlKey ? 'all' : 'none');
});

let stopSimulation = () => {
force.stop();
d3.selectAll("svg#network > *").remove();
}
let stopSimulation = () => force.stop();

$window
.on('stop-force-simulation', stopSimulation)
.on('node-color-change', updateNodeColors)
.on('link-color-change', updateLinkColor)
.on('background-color-change', function () {
$('#network').css('background-color', settings['background-color']);
})
.on('node-visibility link-visibility cluster-visibility node-selected', render)
.on('resize', function () {
.on('background-color-change.2d', function () {
$('#network').css('background-color', settings['background-color']);
})
.on('node-color-change.2d', updateNodeColors)
.on('node-visibility.2d link-visibility.2d cluster-visibility.2d node-selected.2d', render)
.on('link-color-change.2d', updateLinkColor)
.on('resize.2d', function () {
if (session.style.widgets["node-timeline-variable"] != 'None') {
$('#node-timeline-variable').val(session.style.widgets["node-timeline-variable"]).change();
setTimeout(fit, 0);
}
});
})
.on('stop-force-simulation.2d', stopSimulation);

layout.on('stateChanged', function () {
let wrapper = $('#network').parent();
Expand Down
7 changes: 6 additions & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,12 @@
//If anything here seems eccentric, assume it's to maintain compatibility with
//session files from older versions of MicrobeTrace.

$window.trigger("stop-force-simulation"); // stop previous network ticks
$window.trigger("stop-force-simulation"); // stop previous network ticks so previous polygon won't show up

// when using recall function several times, window remembers every registered event function of each recall which all registered functions will be fired when triggered
// since an event is registered in both 2d_network.html and index.js, add namespace to events in 2d_network so they can be removed without affecting events in index
$window.off('.2d');

MT.reset();
$("#launch").prop("disabled", true);
session.files = oldSession.files;
Expand Down

0 comments on commit 081221d

Please sign in to comment.