From aa6f38e0a35306171176b95469deae38b04f827b Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Thu, 5 Jul 2018 21:44:36 -0400 Subject: [PATCH] working! & pretty smooth, with responsive extra click --- src/components/graph/graph.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/components/graph/graph.js b/src/components/graph/graph.js index b70c6027..2d7b8bc9 100644 --- a/src/components/graph/graph.js +++ b/src/components/graph/graph.js @@ -85,8 +85,11 @@ class Graph extends React.Component { camera.tick(); }); + this.reglRenderState = "rendering"; + this.setState({ regl, + drawPoints, pointBuffer, colorBuffer, sizeBuffer, @@ -163,6 +166,16 @@ class Graph extends React.Component { this.state.sizeBuffer({ data: this.renderCache.sizes, dimension: 1 }); this.count = cellCount; + + this.state.regl._refresh(); + this.reglDraw( + this.state.regl, + this.state.drawPoints, + this.state.sizeBuffer, + this.state.colorBuffer, + this.state.pointBuffer, + this.state.camera + ); } if ( @@ -173,7 +186,7 @@ class Graph extends React.Component { /* clear out whatever was on the div, even if nothing, but usually the brushes etc */ d3 .select("#graphAttachPoint") - .selectAll("*") + .selectAll("svg") .remove(); const { svg, brush, brushContainer } = setupSVGandBrushElements( this.handleBrushSelectAction.bind(this), @@ -184,6 +197,13 @@ class Graph extends React.Component { this.setState({ svg, brush, brushContainer }); } } + componentDidUpdate() { + if (this.state.reglRender && this.reglRenderState === "rendering") { + console.log("yeah..."); + this.state.reglRender.cancel(); + this.reglRenderState = "paused"; + } + } handleBrushSelectAction() { /* This conditional handles procedural brush deselect. Brush emits an event on procedural deselect because it is move: null */ if (d3.event.sourceEvent !== null) {