getDimensions

Commons
stable

Calculates the scale and translation values needed to animate an overlay element from a target position. Returns offset coordinates, scale ratios (sx, sy), and a speed multiplier for large elements.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

target
required
HTMLElement | [x: number, y: number]
The anchor target — an HTMLElement whose bounding box is used, or a [x, y] point tuple for pointer-based origins.
el
required
HTMLElement
The overlay element that will be animated. Its bounding box and transform-origin are read to compute the animation parameters.

API

Return value

The value returned by this util.

x/y: translation offset; sx/sy: scale ratios relative to the target; speed: 1.0–1.5 multiplier applied to large elements to slow the animation.

Usage

Examples

Ready-to-paste usage snippets.

Compute overlay animation parameters

typescript