#cy.animate(opts)
// Animate the viewport (pan/zoom) over duration ms
cy.animate(opts: AnimateOptions): thisAnimate the viewport (pan/zoom) over duration ms. Element animation is on the collection (eles.animate). Tweens are CPU-canonical; a data write / manual pan mid-animation is not prevented but will be overwritten by the next tick.
| Name | Description |
|---|---|
opts: AnimateOptions | the viewport targets ( |
Fields of opts
| Name | Description |
|---|---|
style: Record<string, string | number>? | |
position: Partial<Position>? | |
collapsed: boolean? | Target the collapsed state of compound parents. This is an element-only animation channel and may be combined with timing options, but not with other style, position, or viewport targets. |
pan: Position? | viewport targets (core.animate) |
panBy: Position? | viewport target: pan by a delta rather than to an absolute position.
Resolved against the pan at creation time, so a manual
pan afterwards does not move the target. Throws alongside |
zoom: number? | |
fit: { eles?: unknown; boundingBox?: { x1: number; y1: number; x2?: number; y2?: number; w?: number; h?: number; }; padding?: number; }? | viewport target: animate to the viewport that fits the given elements (or an explicit model-space box). Resolved to pan/zoom when the animation is created. |
center: { eles?: unknown }? | viewport target: animate the pan that centers the given elements |
duration: number? | |
easing: string? | A named easing, |
delay: number? | |
complete: () => void? |
thisthis core, for chaining
Example
cy.animate({ pan: { x: 20, y: 10 }, duration: 100 });cy.stop(true);console.log(cy.pan().x); // 20