logo

X6

  • Tutorials
  • API
  • Examples
  • Q&A
  • Change Log
  • XFlow
  • Productsantv logo arrow
  • 2.x
  • Graph
    • Graph
    • Grid
    • Background
    • Panning
    • Mousewheel
    • Viewport Transformation
    • Coordinate Systems
  • Element
    • Cell
    • Node
    • Edge
    • Labels
    • Arrow
    • Element Attributes
    • Interaction
  • MVC
    • Model
    • View
  • Extension
    • Node Tools
    • Edge Tools
    • Routing
    • Connector
    • Node Anchor
    • Edge Anchor
    • Connection Point
    • Port Layout Algorithm
    • Port Label Layout
    • Attributes
    • Highlighter
    • Filter

Panning

Previous
Background
Next
Mousewheel

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-Interactive solution
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Demo

Configuration

A regular canvas (without the scroller plugin) can support panning by enabling the panning option.

Note

Do not use scroller and panning simultaneously, as they conflict with each other in terms of interaction.

const graph = new Graph({
panning: true,
})
// Equivalent to
const graph = new Graph({
panning: {
enabled: true,
},
})

The supported options are as follows:

interface Options {
enabled?: boolean
modifiers?: ModifierKey
eventTypes?: ('leftMouseDown' | 'rightMouseDown' | 'mouseWheel', 'mouseWheelDown')[]
}

enabled

Whether to enable canvas panning interaction.

modifiers

Dragging may conflict with other operations, so you can set the modifiers parameter to specify a modifier key that needs to be pressed along with the mouse click to trigger canvas panning.

The type definition of ModifierKey is as follows:

type ModifierKey = string | ('alt' | 'ctrl' | 'meta' | 'shift' | 'space')[] | null

It supports the following forms:

  • alt represents pressing the alt key.
  • [alt, ctrl] represents pressing either the alt or ctrl key.
  • alt|ctrl represents pressing either the alt or ctrl key.
  • alt&ctrl represents pressing both the alt and ctrl keys simultaneously.
  • alt|ctrl&shift represents pressing both the alt and shift keys simultaneously or pressing both the ctrl and shift keys simultaneously.

eventTypes

The interaction types that trigger canvas panning. It supports three forms or their combinations:

  • leftMouseDown: Dragging by pressing the left mouse button
  • rightMouseDown: Dragging by pressing the right mouse button
  • mouseWheel: Dragging by scrolling the mouse wheel
  • mouseWheelDown: Dragging by pressing the mouse wheel

Methods

isPannable()

isPannable(): boolean

Returns whether canvas panning interaction is enabled.

enablePanning()

enablePanning(): this

Enables canvas panning.

disablePanning()

disablePanning(): this

Disables canvas panning.

togglePanning(...)

togglePanning(enabled?: boolean): this

Toggles the enabled state of canvas panning. The parameter is as follows:

NameTypeRequiredDefault ValueDescription
enabledboolean-Whether to enable canvas panning, defaults to toggling the enabled state.
Selection Settings
Enabled
Modifier Key
Event Type