-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: compute element zindex when add and update data stage
- Loading branch information
antv
committed
Nov 12, 2024
1 parent
0ec431f
commit 20c25aa
Showing
52 changed files
with
810 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/g6/__tests__/bugs/model-add-edge-in-combo.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { createGraph } from '@@/utils'; | ||
|
||
describe('add edge in combo', () => { | ||
it('add edge in combo without zIndex', async () => { | ||
const graph = createGraph({ | ||
data: { | ||
nodes: [ | ||
{ id: 'node-1', combo: 'combo-1', style: { x: 100, y: 100 } }, | ||
{ id: 'node-2', combo: 'combo-1', style: { x: 200, y: 200 } }, | ||
], | ||
combos: [{ id: 'combo-1' }], | ||
}, | ||
}); | ||
|
||
await graph.draw(); | ||
|
||
graph.addEdgeData([{ id: 'edge', source: 'node-1', target: 'node-2' }]); | ||
await graph.draw(); | ||
|
||
expect(graph.getEdgeData('edge').style?.zIndex).toBe(1); | ||
// @ts-expect-error skip the type check | ||
expect(graph.context.element?.getElement('edge')?.style.zIndex).toBe(1); | ||
}); | ||
|
||
it('add edge in combo with zIndex', async () => { | ||
const graph = createGraph({ | ||
data: { | ||
nodes: [ | ||
{ id: 'node-1', combo: 'combo-1', style: { x: 100, y: 100 } }, | ||
{ id: 'node-2', combo: 'combo-1', style: { x: 200, y: 200 } }, | ||
{ id: 'node-3', style: { x: 300, y: 300, zIndex: 5 } }, | ||
], | ||
combos: [{ id: 'combo-1' }], | ||
}, | ||
}); | ||
|
||
await graph.draw(); | ||
|
||
expect(graph.getComboData('combo-1').style?.zIndex).toBe(0); | ||
|
||
await graph.frontElement('combo-1'); | ||
|
||
expect(graph.getComboData('combo-1').style?.zIndex).toBe(5 + 1); | ||
expect(graph.getNodeData('node-1').style?.zIndex).toBe(5 + 1 + 2); | ||
|
||
graph.addEdgeData([{ id: 'edge', source: 'node-1', target: 'node-2' }]); | ||
await graph.draw(); | ||
|
||
expect(graph.getEdgeData('edge').style?.zIndex).toBe(5 + 1 + 1); | ||
// @ts-expect-error skip the type check | ||
expect(graph.context.element?.getElement('edge')?.style.zIndex).toBe(5 + 1 + 1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.