geneviewer-js 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,15 +5,19 @@
5
5
  (function () {
6
6
  // The events sent to Shiny, as the inputs <output id>_<name>
7
7
  var shinyEvents = ["click", "dblclick", "select", "selection", "drag", "moves", "zoom", "rendered"];
8
- // GC_zoom_to(): the chart of each output id
9
- var charts = {};
10
8
  var zoomHandlerAdded = false;
11
9
 
12
10
  var addZoomHandler = function () {
13
11
  if (zoomHandlerAdded || !window.Shiny?.addCustomMessageHandler) return;
14
12
  zoomHandlerAdded = true;
15
13
  Shiny.addCustomMessageHandler("geneviewer-zoom", function (message) {
16
- var chart = charts[message.id];
14
+ // GC_zoom_to(): the chart of the output, found when the message arrives.
15
+ // This binding keeps no list of charts: a chart lives as long as its
16
+ // element, so removing a Shiny output frees it. Nothing here calls
17
+ // destroy(); that is for pages that use the library's newChart() themselves.
18
+ var el = document.getElementById(message.id);
19
+ var widget = el && HTMLWidgets.getInstance(el);
20
+ var chart = widget && widget.getChart();
17
21
  if (chart) chart.zoomTo(message.range);
18
22
  });
19
23
  };
@@ -55,7 +59,6 @@ HTMLWidgets.widget({
55
59
  return;
56
60
  }
57
61
  chart = geneviewer.newChart(el, spec || x, options);
58
- charts[el.id] = chart;
59
62
  },
60
63
  resize: function () {
61
64
  if (chart) chart.resize();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geneviewer-js",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Interactive gene cluster, transcript and genome alignment charts in the browser, drawn with D3",
5
5
  "keywords": [
6
6
  "gene cluster",