Skip to content
Snippets Groups Projects
Commit 872a5921 authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

[js][tc] refactor out old "componentWillReceiveProps" lifecycle func

parent 08ffb11d
No related branches found
No related tags found
1 merge request!7Refactor State Management Milestone
...@@ -134,19 +134,22 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> { ...@@ -134,19 +134,22 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
// initializes d3 behaviours (most SVG interactions) // initializes d3 behaviours (most SVG interactions)
componentDidMount = () => { componentDidMount = () => {
if(this.props.interactable){ this.initD3Behaviours();
this.initD3Drag();
this.initD3Connections();
this.initD3AreaSelect();
this.initD3MouseMovement();
}
this.fitToToolchain(this.getLocationMap()); this.fitToToolchain(this.getLocationMap());
//this.scrollToMiddle(); //this.scrollToMiddle();
} }
// initalize all the d3 behaviours again (they overwrite older ones) // initalize all the d3 behaviours again if the tc changed,
componentWillReceiveProps = (nextProps: Props) => { // so new blocks have the d3 stuff and old blocks are removed
if(nextProps.interactable){ // (they overwrite older ones)
componentDidUpdate = (prevProps: Props, prevState: State, snapshot: any) => {
if(prevProps !== this.props){
this.initD3Behaviours();
}
}
initD3Behaviours = () => {
if(this.props.interactable){
this.initD3Drag(); this.initD3Drag();
this.initD3Connections(); this.initD3Connections();
this.initD3AreaSelect(); this.initD3AreaSelect();
...@@ -397,7 +400,6 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> { ...@@ -397,7 +400,6 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
return; return;
const that = this; const that = this;
// currently debouncing isnt necessary perf-wise // currently debouncing isnt necessary perf-wise
//let debouceTimeLast = 0;
let startX = 0; let startX = 0;
let startY = 0; let startY = 0;
let dx = 0; let dx = 0;
...@@ -406,11 +408,6 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> { ...@@ -406,11 +408,6 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
let my = 0; let my = 0;
// the event handler for all the drag events in between the start/end // the event handler for all the drag events in between the start/end
function dragged(d) { function dragged(d) {
/*
if(Date.now() - debouceTimeLast < 10)
return;
*/
// keep track of the change to mouse location across drag events // keep track of the change to mouse location across drag events
dx += d3.event.dx; dx += d3.event.dx;
dy += d3.event.dy; dy += d3.event.dy;
...@@ -434,8 +431,6 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> { ...@@ -434,8 +431,6 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
// reset the grid movement since we made it already // reset the grid movement since we made it already
mx = 0; mx = 0;
my = 0; my = 0;
//debouceTimeLast = Date.now();
} }
// when the user starts dragging, create the placeholder block // when the user starts dragging, create the placeholder block
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment