Skip to content

Commit 5e84bcf

Browse files
committed
docs: update the scroll-canvas docs
1 parent 9689fe7 commit 5e84bcf

File tree

4 files changed

+100
-3
lines changed

4 files changed

+100
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- feat: scroll-canvas behavior;
66
- feat: iconfont for node icon;
7+
- feat: percentage of scalable range for drag-canvas;
78
- fix: missing brushStyle in type ModeOption;
89
- fix: the comboId remains in the node after uncombo(), closes #2801;
910
- fix: disappearing edges when combos are expanded/collapsed, closes #2798;

packages/site/docs/manual/middle/states/defaultBehavior.en.md

+50-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ const graph = new G6.Graph({
106106
- `direction`: The direction of dragging that is allowed. Options: `'x'`, `'y'`, `'both'`. `'both'` by default;
107107
- `enableOptimize`: whether enable optimization, `false` by default. `enableOptimize: true` means hiding all edges and the shapes beside keyShapes of nodes while dragging canvas;
108108
- `shouldBegin(e)`: Whether allow the behavior happen on the current item (e.item);
109-
- `scalableRange`: scaleable range when drag canvas, `zero` by default;
109+
- `scalableRange`: scalable range when drag canvas, `zero` by default. -1 to 1 means the scalable percentage of the viewport; the image bellow illustrate the situation when it is smaller than -1 or bigger than 1:
110+
111+
<img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*IFfoS67_HssAAAAAAAAAAAAAARQnAQ' width='650' alt="" />
112+
110113
- `allowDragOnItem`: whether response when the users drag on items(node/edge/combo), `false` by default;
111114
- Related timing events:
112115
- `canvas:dragstart`: Triggered when drag start. Listened by `graph.on('canvas:dragstart', e => {...})`;
@@ -142,6 +145,51 @@ const graph = new G6.Graph({
142145

143146
The canvas can be dragged along x direction only.<br /><img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*54yxRrW1A7sAAAAAAAAAAABkARQnAQ' width=400 alt='img'/>
144147

148+
149+
### scroll-canvas
150+
151+
- Description: Scroll the canvas by wheeling, *supported after v4.2.6*;
152+
- Configurations:
153+
- `type: 'scroll-canvas'`;
154+
- `direction`: The direction of dragging that is allowed. Options: `'x'`, `'y'`, `'both'`. `'both'` by default;
155+
- `enableOptimize`: whether enable optimization, `false` by default. `enableOptimize: true` means hiding all edges and the shapes beside keyShapes of nodes while dragging canvas;
156+
- `zoomKey`: switch to zooming while pressing the key and wheeling. Options: `'shift'`, `'ctrl'`, `'alt'`, `'control'`;
157+
- `scalableRange`: scalable range when drag canvas, `zero` by default. -1 to 1 means the scalable percentage of the viewport; the image bellow illustrate the situation when it is smaller than -1 or bigger than 1:
158+
159+
<img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*IFfoS67_HssAAAAAAAAAAAAAARQnAQ' width='650' alt="" />
160+
161+
- Related timing events:
162+
- `wheel`: Triggered when wheeling. Listened by `graph.on('wheel', e => {...})`.
163+
164+
**Using Default Configuration**
165+
166+
```javascript
167+
const graph = new G6.Graph({
168+
modes: {
169+
default: ['drag-canvas'],
170+
},
171+
});
172+
```
173+
174+
By default, the x and y directions are both allowed.
175+
176+
**Using Customized Configuration**
177+
178+
```javascript
179+
const graph = new G6.Graph({
180+
modes: {
181+
default: [
182+
{
183+
type: 'drag-canvas',
184+
direction: 'x',
185+
},
186+
],
187+
},
188+
});
189+
```
190+
191+
The canvas can be dragged along x direction only.<br /><img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*54yxRrW1A7sAAAAAAAAAAABkARQnAQ' width=400 alt='img'/>
192+
145193
### zoom-canvas
146194

147195
- Description: Zoom the canvas;
@@ -163,6 +211,7 @@ The canvas can be dragged along x direction only.<br /><img src='https://gw.alip
163211

164212
**Tips: Assign values for `minZoom` and  `maxZoom` on the graph to limit the zooming ratio.**
165213

214+
166215
### drag-node
167216

168217
- Description: Allows users drag nodes;

packages/site/docs/manual/middle/states/defaultBehavior.zh.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const graph = new G6.Graph({
108108
- `enableOptimize`:是否开启优化,开启后拖动画布过程中隐藏所有的边及节点上非 keyShape 部分,默认关闭;
109109
- `shouldBegin(e)`:是否允许触发该操作;
110110
- `allowDragOnItem`:是否允许用户在节点/边/ combo 上拖拽时响应,默认为 false;
111-
- `scalableRange`:拖动 canvas 可扩展的范围,默认为 0,取值为正和负数时的效果如下图所示
111+
- `scalableRange`:拖动 canvas 可扩展的范围,默认为 0,值为 -1 ~ 1 代表可超出视口的范围的比例值(相对于视口大小)。值小于 -1 或大于 1 时,为正和负数时的效果如下图所示
112112

113113
<img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*IFfoS67_HssAAAAAAAAAAAAAARQnAQ' width='650' />
114114

@@ -146,6 +146,53 @@ const graph = new G6.Graph({
146146

147147
此时只能在 x 方向上面拖动,y 方向上不允许拖动。<br /><img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*54yxRrW1A7sAAAAAAAAAAABkARQnAQ' width=400 alt='img'/>
148148

149+
150+
### scroll-canvas
151+
152+
- 含义:滚轮滚动画布,*v4.2.6 起支持*
153+
- 配置项:
154+
155+
- `type: 'scroll-canvas'`
156+
- `direction`:允许拖拽方向,支持`'x'``'y'``'both'`,默认方向为 `'both'`
157+
- `enableOptimize`:是否开启优化,开启后拖动画布过程中隐藏所有的边及节点上非 keyShape 部分,默认关闭;
158+
- `zoomKey`:切换为滚动缩放的键盘按钮,按住该键并滚动滚轮,则切换为滚轮缩放画布,可选项为:`'shift'``'ctrl'``'alt'``'control'`
159+
- `scalableRange`:拖动 canvas 可扩展的范围,默认为 0,值为 -1 ~ 1 代表可超出视口的范围的比例值(相对于视口大小)。值小于 -1 或大于 1 时,为正和负数时的效果如下图所示。
160+
161+
<img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*IFfoS67_HssAAAAAAAAAAAAAARQnAQ' width='650' alt="" />
162+
163+
- 相关时机事件:
164+
- `onWheel`:滚轮滚动时触发,使用 `graph.on('onWheel', e => {...})` 监听。
165+
166+
**使用默认配置**
167+
168+
```javascript
169+
const graph = new G6.Graph({
170+
modes: {
171+
default: ['scroll-canvas'],
172+
},
173+
});
174+
```
175+
176+
默认配置下,可以在 x 和 y 两个方向上滚动画布。
177+
178+
**使用自定义参数**
179+
180+
```javascript
181+
const graph = new G6.Graph({
182+
modes: {
183+
default: [
184+
{
185+
type: 'scroll-canvas',
186+
direction: 'x',
187+
},
188+
],
189+
},
190+
});
191+
```
192+
193+
此时只能在 x 方向上面滚动,y 方向上不允许滚动。<br /><img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*54yxRrW1A7sAAAAAAAAAAABkARQnAQ' width=400 alt='img'/>
194+
195+
149196
### zoom-canvas
150197

151198
- 含义:缩放画布;

packages/site/examples/algorithm/algoDemos/demo/louvain.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const graph = new G6.Graph({
3434
default: ['drag-canvas', 'drag-node', 'zoom-canvas'],
3535
},
3636
layout: {
37-
// type: 'gForce',
37+
type: 'gForce',
3838
minMovement: 0.1,
3939
},
4040
});

0 commit comments

Comments
 (0)