UNPKG

@lagrange/animator

Version:

This library helps making parallax animations on scroll. It is built with performance in mind, as it doesn't need to relayout or paint to operate.

19 lines (14 loc) 473 B
import { fromString, matrix2dto3d } from '../utils/CssMatrix'; /** * @param {HTMLElement} elem */ export function getInitialMatrix(elem, is3D = false) { const prev = elem.style.transform; elem.style.transform = ''; const transform = window.getComputedStyle(elem).getPropertyValue('transform'); elem.style.transform = prev; if (transform === 'none') return null; let m = fromString(transform); m = (m.length < 16 && is3D) ? matrix2dto3d(m) : m; return m; }