Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.editor
Commits
872a5921
Commit
872a5921
authored
6 years ago
by
Jaden DIEFENBAUGH
Browse files
Options
Downloads
Patches
Plain Diff
[js][tc] refactor out old "componentWillReceiveProps" lifecycle func
parent
08ffb11d
No related branches found
No related tags found
1 merge request
!7
Refactor State Management Milestone
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
conda/js/src/components/toolchain/GraphicalEditor.jsx
+12
-17
12 additions, 17 deletions
conda/js/src/components/toolchain/GraphicalEditor.jsx
with
12 additions
and
17 deletions
conda/js/src/components/toolchain/GraphicalEditor.jsx
+
12
−
17
View file @
872a5921
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment