Skip to content

API reference

cy.pan — Core > Viewport manipulation > Pan, zoom, fit and bounds. Cytoscape.js signatures, parameters and return contract.

cy.pan — Core › Viewport manipulation › Pan, zoom, fit and bounds

Preview · Core › Viewport manipulation › Pan, zoom, fit and bounds

Read in the complete API reference · All API members

#cy.pan()

// Get the pan position
cy.pan(): Position

Read the current pan offset in rendered CSS pixels.

Returns Position

the rendered-space offset

Example

cy.pan({ x: 40, y: 20 });
console.log(cy.pan()); // { x: 40, y: 20 }

Example graph and handle setup

#cy.pan(pan)

// Set the pan position
cy.pan(pan: Position): this

// Set the pan position
cy.pan(pan: Position | undefined): Position | this

Set the pan offset. A no-op while panningEnabled() is false.

Parameters
NameDescription
pan: Position

the new rendered-space offset

Fields of pan
NameDescription
x: number
y: number
Returns this

this core, for chaining

Example

const result = cy.pan({ x: 40, y: 20 });
console.log(result === cy); // true

Example graph and handle setup

Get the pan offset, or set it. Setting is a no-op while panningEnabled() is false.

Parameters
NameDescription
pan: Position | undefined

the new rendered-space offset; omit to read

Fields of pan
NameDescription
x: number
y: number
Returns Position | this

the current pan when reading, this core when setting

Example

cy.pan({ x: 40, y: 20 });
console.log(cy.pan()); // { x: 40, y: 20 }

Example graph and handle setup