Skip to content

Commit 0f0f5f5

Browse files
q32757468heshenglei
andauthored
feat: panning option default value set to true (#4835)
Co-authored-by: heshenglei <[email protected]>
1 parent e071dca commit 0f0f5f5

File tree

17 files changed

+36
-21
lines changed

17 files changed

+36
-21
lines changed

__tests__/plugin/__snapshots__/stencil-1.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class="x6-widget-stencil-group-content"
2020
>
2121
<div
22-
class="x6-graph"
22+
class="x6-graph x6-graph-pannable"
2323
style="width: 200px; height: 800px;"
2424
>
2525
<div
@@ -141,7 +141,7 @@
141141
class="x6-widget-stencil-group-content"
142142
>
143143
<div
144-
class="x6-graph"
144+
class="x6-graph x6-graph-pannable"
145145
style="width: 200px; height: 800px;"
146146
>
147147
<div

__tests__/plugin/__snapshots__/stencil-2.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class="x6-widget-stencil-group-content"
2020
>
2121
<div
22-
class="x6-graph"
22+
class="x6-graph x6-graph-pannable"
2323
style="width: 200px; height: 800px;"
2424
>
2525
<div
@@ -141,7 +141,7 @@
141141
class="x6-widget-stencil-group-content"
142142
>
143143
<div
144-
class="x6-graph"
144+
class="x6-graph x6-graph-pannable"
145145
style="width: 200px; height: 800px;"
146146
>
147147
<div

__tests__/plugin/__snapshots__/stencil-3.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class="x6-widget-stencil-group-content"
2020
>
2121
<div
22-
class="x6-graph"
22+
class="x6-graph x6-graph-pannable"
2323
style="width: 200px; height: 800px;"
2424
>
2525
<div
@@ -106,7 +106,7 @@
106106
class="x6-widget-stencil-group-content"
107107
>
108108
<div
109-
class="x6-graph"
109+
class="x6-graph x6-graph-pannable"
110110
style="width: 200px; height: 800px;"
111111
>
112112
<div

__tests__/plugin/scroller.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function createMockGraph() {
3333
container,
3434
view: { grid: document.createElement('div'), background: null },
3535
grid: { update: vi.fn(), draw: vi.fn(), clear: vi.fn() }, // ✅ mock grid
36+
panning: { pannable: true },
3637
transform: {
3738
getScale: () => ({ sx: 1, sy: 1 }),
3839
resize: vi.fn(),

examples/src/pages/auto-resize/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react'
21
import { SplitBox } from '@antv/x6-react-components'
2+
import React from 'react'
33
import '@antv/x6-react-components/es/split-box/style/index.css'
44
import { Graph, Scroller } from '@antv/x6'
55
import '../index.less'

examples/src/pages/minimap/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as React from 'react'
2-
import { Radio } from 'antd'
31
import { Graph, MiniMap, Scroller } from '@antv/x6'
2+
import { Radio } from 'antd'
3+
import * as React from 'react'
44
import { SimpleNodeView } from './simple-view'
55
import './index.less'
66

@@ -19,6 +19,7 @@ export default class Example extends React.Component {
1919
container: this.container,
2020
width: 600,
2121
height: 320,
22+
panning: false,
2223
background: {
2324
color: '#F2F7FA',
2425
},

examples/src/pages/plugins/scroller/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react'
1+
import { Export, Graph, MiniMap, Scroller, Selection } from '@antv/x6'
22
import { Button } from 'antd'
3-
import { Graph, Export, Selection, MiniMap, Scroller } from '@antv/x6'
3+
import React from 'react'
44
import '../../index.less'
55
import './index.less'
66

@@ -23,6 +23,7 @@ export class ScrollerExample extends React.Component {
2323
grid: {
2424
visible: true,
2525
},
26+
panning: false,
2627
mousewheel: {
2728
enabled: true,
2829
// fixed: false,

examples/src/pages/virtual-render/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import React, { useEffect, useRef } from 'react'
2-
import { Graph, Cell, Scroller } from '@antv/x6'
1+
import { type Cell, Graph, Scroller } from '@antv/x6'
2+
import type React from 'react'
3+
import { useEffect, useRef } from 'react'
34
import '../index.less'
45
import './index.less'
56

@@ -16,6 +17,7 @@ export const VirtualRenderExample: React.FC = () => {
1617
height: 800,
1718
grid: true,
1819
mousewheel: true,
20+
panning: false,
1921
virtual: true,
2022
})
2123

site/docs/api/graph/graph.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ new Graph(options: Options)
2020
| height | `number` | | 画布高度,默认使用容器高度。 | - |
2121
| scaling | `{ min?: number, max?: number }` | | 画布的最小最大缩放级别。 | `{ min: 0.01, max: 16 }` |
2222
| [autoResize](/tutorial/basic/graph#画布大小) | `boolean \| Element \| Document` | | 是否监听容器大小改变,并自动更新画布大小。 | `false` |
23-
| [panning](/api/graph/panning) | `boolean \| PanningManager.Options` | | 画布是否可以拖拽平移,默认禁用| `false` |
23+
| [panning](/api/graph/panning) | `boolean \| PanningManager.Options` | | 画布是否可以拖拽平移,默认启用| `true` |
2424
| [mousewheel](/api/graph/mousewheel) | `boolean \| MouseWheel.Options` | | 鼠标滚轮缩放,默认禁用。 | `false` |
2525
| [grid](/api/graph/grid) | `boolean \| number \| GridManager.Options` | | 网格,默认使用 `10px` 的网格,但不绘制网格背景。 | `false` |
2626
| [background](/api/graph/background) | `false \| BackgroundManager.Options` | | 背景,默认不绘制背景。 | `false` |

site/docs/api/graph/panning.zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ redirect_from:
1616
普通画布(未使用 `scroller` 插件)通过开启 `panning` 选项来支持拖拽平移。
1717

1818
:::warning{title=注意}
19-
不要同时使用 `scroller``panning`,因为两种形式在交互上有冲突。
19+
不要同时使用 `scroller``panning`,因为两种形式在交互上有冲突。从 2.19.0 版本开始,`panning` 配置默认值为 `true`
2020
:::
2121

2222
```ts
2323
const graph = new Graph({
24-
panning: true,
24+
panning: true, // 不传该选项时,默认值也为 true
2525
})
2626

2727
// 等同于

0 commit comments

Comments
 (0)