Skip to content

Commit

Permalink
fix: sync render when change position (antvis#2860)
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored Nov 9, 2022
1 parent e683155 commit 2194769
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions packages/x6/src/renderer/queueJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ export class JobQueue {
private initialTime = Date.now()

queueJob(job: Job) {
const index = this.findInsertionIndex(job)
if (index >= 0) {
this.queue.splice(index, 0, job)
if (job.priority === JOB_PRIORITY.PRIOR) {
job.cb()
} else {
const index = this.findInsertionIndex(job)
if (index >= 0) {
this.queue.splice(index, 0, job)
}
}
}

Expand Down Expand Up @@ -133,6 +137,7 @@ export enum JOB_PRIORITY {
RenderEdge = 1,
RenderNode = 2,
Update = 3,
PRIOR = 100,
}

// function findInsertionIndex(job: Job) {
Expand Down
6 changes: 6 additions & 0 deletions packages/x6/src/renderer/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export class Scheduler extends Disposable {
viewItem.flag = flag
viewItem.options = options

const positionFlag = view.getFlag(['translate', 'tools'])
if (view.isNodeView() && flag === positionFlag) {
priority = JOB_PRIORITY.PRIOR // eslint-disable-line
flush = false // eslint-disable-line
}

this.queue.queueJob({
id,
priority,
Expand Down
4 changes: 2 additions & 2 deletions packages/x6/src/shape/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export namespace HTML {
},
})

NodeView.registry.register('html-view', View)
NodeView.registry.register('html-view', View, true)
}
}

Expand Down Expand Up @@ -103,7 +103,7 @@ export namespace HTML {
},
})

Node.registry.register('html', HTML)
Node.registry.register('html', HTML, true)
}

export namespace HTML {
Expand Down

0 comments on commit 2194769

Please sign in to comment.