Web Dev Solutions

Catalin Mititiuc

From 2d3fc1cd22ffcc61ec178eeaf97f3a4d7cba98bf Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Sat, 20 Apr 2024 19:34:06 -0700 Subject: Use CSS transformations instead of manipulating the viewBox --- src/modules/utils.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/modules/utils.js (limited to 'src/modules/utils.js') diff --git a/src/modules/utils.js b/src/modules/utils.js new file mode 100644 index 0000000..e7f5c55 --- /dev/null +++ b/src/modules/utils.js @@ -0,0 +1,8 @@ +const digits = /-?\d+\.?\d*/g; + +export default function getComputedTransformMatrix(el) { + const matrixSequence = getComputedStyle(el).transform.match(digits), + identityMatrix = ''; + + return new DOMMatrix(matrixSequence || identityMatrix); +} -- cgit v1.2.3