Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
X6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Synced
X6
Commits
2a3e523b
Unverified
Commit
2a3e523b
authored
2 years ago
by
vector
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: refactor cell remove schedule (#3154)
parent
b5af7844
Branches
pre-release-4.4.6
Branches containing commit
Tags
prepare-4.4.6
v4.4.6
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/x6/src/renderer/scheduler.ts
+51
-21
51 additions, 21 deletions
packages/x6/src/renderer/scheduler.ts
with
51 additions
and
21 deletions
packages/x6/src/renderer/scheduler.ts
+
51
−
21
View file @
2a3e523b
...
...
@@ -8,6 +8,7 @@ import { Graph } from '../graph'
export
class
Scheduler
extends
Disposable
{
public
views
:
KeyValue
<
Scheduler
.
View
>
=
{}
public
willRemoveViews
:
KeyValue
<
Scheduler
.
View
>
=
{}
protected
zPivots
:
KeyValue
<
Comment
>
private
graph
:
Graph
private
renderArea
?:
Rectangle
...
...
@@ -51,7 +52,7 @@ export class Scheduler extends Disposable {
protected
onModelReseted
({
options
}:
Model
.
EventArgs
[
'
reseted
'
])
{
this
.
queue
.
clearJobs
()
this
.
removeZPivots
()
this
.
re
move
Views
()
this
.
re
set
Views
()
this
.
renderViews
(
this
.
model
.
getCells
(),
options
)
}
...
...
@@ -59,12 +60,8 @@ export class Scheduler extends Disposable {
this
.
renderViews
([
cell
],
options
)
}
protected
onCellRemoved
({
cell
,
options
}:
Model
.
EventArgs
[
'
cell:removed
'
])
{
const
viewItem
=
this
.
views
[
cell
.
id
]
if
(
viewItem
)
{
const
view
=
viewItem
.
view
this
.
requestViewUpdate
(
view
,
Scheduler
.
FLAG_REMOVE
,
options
)
}
protected
onCellRemoved
({
cell
}:
Model
.
EventArgs
[
'
cell:removed
'
])
{
this
.
removeViews
([
cell
])
}
protected
onCellZIndexChanged
({
...
...
@@ -186,7 +183,7 @@ export class Scheduler extends Disposable {
viewItem
.
view
,
flag
,
options
,
cell
.
isNode
()
?
JOB_PRIORITY
.
RenderNode
:
JOB_PRIORITY
.
RenderEdge
,
this
.
getRenderPriority
(
viewItem
.
view
)
,
false
,
)
}
...
...
@@ -234,6 +231,28 @@ export class Scheduler extends Disposable {
}
}
protected
removeViews
(
cells
:
Cell
[])
{
cells
.
forEach
((
cell
)
=>
{
const
id
=
cell
.
id
const
viewItem
=
this
.
views
[
id
]
if
(
viewItem
)
{
this
.
willRemoveViews
[
id
]
=
viewItem
delete
this
.
views
[
id
]
this
.
queue
.
queueJob
({
id
,
priority
:
this
.
getRenderPriority
(
viewItem
.
view
),
cb
:
()
=>
{
this
.
removeView
(
viewItem
.
view
)
},
})
}
})
this
.
flush
()
}
protected
flush
()
{
this
.
graph
.
options
.
async
?
this
.
queue
.
queueFlush
()
...
...
@@ -246,10 +265,13 @@ export class Scheduler extends Disposable {
const
viewItem
=
this
.
views
[
ids
[
i
]]
if
(
viewItem
&&
viewItem
.
state
===
Scheduler
.
ViewState
.
WAITTING
)
{
const
{
view
,
flag
,
options
}
=
viewItem
const
priority
=
view
.
cell
.
isNode
()
?
JOB_PRIORITY
.
RenderNode
:
JOB_PRIORITY
.
RenderEdge
this
.
requestViewUpdate
(
view
,
flag
,
options
,
priority
,
false
)
this
.
requestViewUpdate
(
view
,
flag
,
options
,
this
.
getRenderPriority
(
view
),
false
,
)
}
}
...
...
@@ -295,23 +317,25 @@ export class Scheduler extends Disposable {
}
}
protected
removeViews
()
{
Object
.
keys
(
this
.
views
).
forEach
((
id
)
=>
{
const
viewItem
=
this
.
views
[
id
]
protected
resetViews
()
{
this
.
willRemoveViews
=
{
...
this
.
views
}
Object
.
keys
(
this
.
willRemoveViews
).
forEach
((
id
)
=>
{
const
viewItem
=
this
.
willRemoveViews
[
id
]
if
(
viewItem
)
{
this
.
removeView
(
viewItem
.
view
.
cell
)
this
.
removeView
(
viewItem
.
view
)
}
})
this
.
views
=
{}
this
.
willRemoveViews
=
{}
}
protected
removeView
(
cell
:
Cell
)
{
const
viewItem
=
this
.
views
[
cell
.
id
]
if
(
viewItem
)
{
protected
removeView
(
view
:
CellView
)
{
const
cell
=
view
.
cell
const
viewItem
=
this
.
willRemoveViews
[
cell
.
id
]
if
(
view
)
{
viewItem
.
view
.
remove
()
delete
this
.
v
iews
[
cell
.
id
]
delete
this
.
willRemoveV
iews
[
cell
.
id
]
}
return
viewItem
.
view
}
protected
toggleVisible
(
cell
:
Cell
,
visible
:
boolean
)
{
...
...
@@ -455,6 +479,12 @@ export class Scheduler extends Disposable {
)
}
protected
getRenderPriority
(
view
:
CellView
)
{
return
view
.
cell
.
isNode
()
?
JOB_PRIORITY
.
RenderNode
:
JOB_PRIORITY
.
RenderEdge
}
@
Disposable
.
dispose
()
dispose
()
{
this
.
stopListening
()
...
...
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