-
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.
feat(behaviors): add drag node behavior (#5503)
* refactor: export idOf util * refactor(runtime): setElementVisibility support set animation individually * feat(utils): add setCacheStyle util * fix(runtime): fix issue that setVisibility call in a short period of time * fix(elements): fix edge arrow that create and animate error * refactor(elements): adjust nodelike default style props' * feat(behaviors): add drag node behavior * test(behaviors): add drag node test snapshots * test(behavior): update test case and snapshot * refactor: adjust exports
- Loading branch information
Showing
35 changed files
with
2,823 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Graph } from '@/src'; | ||
import type { STDTestCase } from '../types'; | ||
|
||
export const behaviorDragNode: STDTestCase = async (context) => { | ||
const graph = new Graph({ | ||
...context, | ||
data: { | ||
nodes: [ | ||
{ id: 'node-1', style: { x: 100, y: 100 } }, | ||
{ id: 'node-2', style: { x: 200, y: 100, parentId: 'combo-1' } }, | ||
{ id: 'node-3', style: { x: 100, y: 200 } }, | ||
{ id: 'node-4', style: { x: 200, y: 200, parentId: 'combo-1' } }, | ||
], | ||
edges: [ | ||
{ source: 'node-1', target: 'node-2' }, | ||
{ source: 'node-2', target: 'node-4' }, | ||
{ source: 'node-1', target: 'node-3' }, | ||
{ source: 'node-3', target: 'node-4' }, | ||
], | ||
combos: [{ id: 'combo-1' }], | ||
}, | ||
node: { style: { size: 20 } }, | ||
edge: { | ||
style: { endArrow: true }, | ||
}, | ||
behaviors: [{ type: 'drag-node' }], | ||
}); | ||
|
||
await graph.render(); | ||
|
||
behaviorDragNode.form = (panel) => { | ||
const config = { | ||
enable: true, | ||
hideEdges: 'none', | ||
shadow: false, | ||
}; | ||
const handleChange = () => { | ||
graph.setBehaviors([{ type: 'drag-node', ...config }]); | ||
}; | ||
return [ | ||
panel.add(config, 'enable').onChange(handleChange), | ||
panel.add(config, 'hideEdges', ['none', 'in', 'out', 'both']).onChange(handleChange), | ||
panel.add(config, 'shadow').onChange(handleChange), | ||
]; | ||
}; | ||
|
||
return graph; | ||
}; |
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
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
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.
Oops, something went wrong.