-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add DragNodeWithForce Behaviors
- Loading branch information
1 parent
89f7696
commit c03a176
Showing
3 changed files
with
44 additions
and
0 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,30 @@ | ||
import React from 'react'; | ||
import Graphin, { Utils, Behaviors } from '@antv/graphin'; | ||
import { Toolbar } from '@antv/graphin-components'; | ||
import { Switch } from 'antd'; | ||
|
||
const data = Utils.mock(6).circle().graphin(); | ||
const layout = { | ||
type: 'graphin-force', | ||
}; | ||
|
||
const { DragNodeWithForce } = Behaviors; | ||
|
||
export default () => { | ||
const [autoPin, setAutoPin] = React.useState(false); | ||
const onChange = checked => { | ||
setAutoPin(checked); | ||
}; | ||
return ( | ||
<div> | ||
<Graphin data={data} layout={layout}> | ||
<DragNodeWithForce autoPin={autoPin} /> | ||
<Toolbar> | ||
<Toolbar.Item> | ||
被拖拽的节点,是否自动固定住 <Switch defaultChecked onChange={onChange} checked={autoPin} /> | ||
</Toolbar.Item> | ||
</Toolbar> | ||
</Graphin> | ||
</div> | ||
); | ||
}; |
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