Skip to content

API reference

cy.wheelBehavior — Core > Interaction controls. Cytoscape.js signatures, parameters and return contract.

cy.wheelBehavior — Core › Interaction controls

Preview · Core › Interaction controls

Read in the complete API reference · All API members

#cy.wheelBehavior()

// What a wheel over the canvas does: 'zoom' (the default) zooms about the cursor; 'pan' pans by the wheel's delta and emits scrollpan, while a ctrl- or meta-wheel — the encoding a trackpad pinch arrives in — still zooms; 'modifier-zoom' leaves the plain wheel to the page (it scrolls past the graph) and zooms only on a ctrl- or meta-wheel
cy.wheelBehavior(): WheelBehavior

What a wheel over the canvas does: 'zoom' (the default) zooms about the cursor; 'pan' pans by the wheel's delta and emits a scrollpan event, while a ctrl- or meta-wheel — the encoding a trackpad pinch arrives in — still zooms; 'modifier-zoom' leaves the plain wheel to the page (it scrolls past the graph) and zooms only on a ctrl- or meta-wheel. Every mode honours the toggles (userZoomingEnabled gates a zoom, userPanningEnabled a pan), and a wheel the settings leave inert is not preventDefault()ed, so the page scrolls in every mode.

Returns WheelBehavior

the current wheelBehavior value

Example

console.log(cy.wheelBehavior()); // "zoom"

Example graph and handle setup

Throws

if mode is not 'zoom', 'pan' or 'modifier-zoom'

#cy.wheelBehavior(mode)

// What a wheel over the canvas does: 'zoom' (the default) zooms about the cursor; 'pan' pans by the wheel's delta and emits scrollpan, while a ctrl- or meta-wheel — the encoding a trackpad pinch arrives in — still zooms; 'modifier-zoom' leaves the plain wheel to the page (it scrolls past the graph) and zooms only on a ctrl- or meta-wheel
cy.wheelBehavior(mode: WheelBehavior): this

What a wheel over the canvas does: 'zoom' (the default) zooms about the cursor; 'pan' pans by the wheel's delta and emits a scrollpan event, while a ctrl- or meta-wheel — the encoding a trackpad pinch arrives in — still zooms; 'modifier-zoom' leaves the plain wheel to the page (it scrolls past the graph) and zooms only on a ctrl- or meta-wheel. Every mode honours the toggles (userZoomingEnabled gates a zoom, userPanningEnabled a pan), and a wheel the settings leave inert is not preventDefault()ed, so the page scrolls in every mode.

Parameters
NameDescription
mode: WheelBehavior

the behaviour to set

Returns this

this core, for chaining

Example

const result = cy.wheelBehavior("zoom");
console.log(result === cy); // true

Example graph and handle setup

Throws

if mode is not 'zoom', 'pan' or 'modifier-zoom'