Skip to content

Commit

Permalink
Use timeout to ensure the canvas is available before rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamRClark committed Nov 18, 2020
1 parent 24b1285 commit 60ee814
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"devDependencies": {
"bluebird": "^3.5.1",
"browserify-css": "^0.14.0",
"canvas-prebuilt": "^1.6.5-prerelease.1",
"chai": "^4.1.2",
"coffee-script": "^1.12.2",
"coffeeify": "^2.0.1",
Expand All @@ -40,6 +39,7 @@
"jest-enzyme": "^4.0.1",
"jsjob": "^0.10.13",
"mocha": "^4.1.0",
"noflo-canvas": "0.4.2",
"react": "^15.6.2",
"react-dom": "^15.6.2",
"react-test-renderer": "^15.6.2",
Expand Down
11 changes: 7 additions & 4 deletions the-graph/the-graph-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,13 @@ module.exports.register = function (context) {
this.refs.graph.markDirty();
},
componentDidUpdate: function (prevProps, prevState) {
this.renderCanvas(this.bgContext);
if (!prevState || prevState.x!==this.state.x || prevState.y!==this.state.y || prevState.scale!==this.state.scale) {
this.onPanScale();
}
setTimeout(function () {
this.renderCanvas(this.bgContext);
if (!prevState || prevState.x!==this.state.x || prevState.y!==this.state.y || prevState.scale!==this.state.scale) {
this.onPanScale();
}
}, 0);

},
renderCanvas: function (c) {
// Comment this line to go plaid
Expand Down

0 comments on commit 60ee814

Please sign in to comment.