fn
getTranslate
v0.0.5Reads the current translation of an element along one axis from
its computed transform, parsing both matrix(...) (2D) and matrix3d(...)
(3D) forms. Returns null when the element has no matrix transform.
Example
ts
const offset = getTranslate(panel, 'y'); // px the panel is shifted downSignature
ts
declare function getTranslate(element: HTMLElement, axis: TranslateAxis): number | null;Parameters
| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | The element to measure |
axis | TranslateAxis | 'x' for horizontal, 'y' for vertical |
Returns
number | nullThe translation in pixels, or null if none