Skip to content

Commit

Permalink
docs: add DragNodeWithForce Behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Mar 8, 2021
1 parent 89f7696 commit c03a176
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/graphin/docs/behaviors/demos/drag-force-node.tsx
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>
);
};
7 changes: 7 additions & 0 deletions packages/graphin/docs/behaviors/node.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ nav:
order: 1
---

## DragNodeWithForce

> Under force layout, drag nodes are automatically fixed, currently only supports `graphin-force` layout
<code src='./demos/drag-force-node.tsx'>
<API src='../../src/behaviors/DragNodeWithForce.tsx'>

## DragNode

<API src='../../src/behaviors/DragNode.tsx'>
Expand Down
7 changes: 7 additions & 0 deletions packages/graphin/docs/behaviors/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ nav:
order: 1
---

## DragNodeWithForce

> 力导布局状态下,拖拽节点是否自动固定,目前仅支持`graphin-force` 布局
<code src='./demos/drag-force-node.tsx'>
<API src='../../src/behaviors/DragNodeWithForce.tsx'>

## DragNode

<API src='../../src/behaviors/DragNode.tsx'>
Expand Down

0 comments on commit c03a176

Please sign in to comment.