Skip to content

cy.resize()

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

cy.resize — 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

// Re-measure the container, redraw and emit 'resize' (the redraw is a no-op when headless; the event still fires)
cy.resize(): this

Re-measure the container, redraw and emit a resize event (the redraw is a no-op when headless; the event still fires).

Rarely needed: a ResizeObserver on the container re-measures on every size change and emits a resize event itself — once per change, and not again for a change this call already applied — so container size changes are handled automatically. Call it where no observer exists or none can see the change.

Returns this

this core

Example

// After the graph container changes size, refresh viewport dimensions.
cy.resize();
console.log(cy.width() > 0); // true

Example graph and handle setup

Also spelled cy.invalidateSize.