Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-04-20 19:34:06 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-04-23 10:09:51 -0700
commit2d3fc1cd22ffcc61ec178eeaf97f3a4d7cba98bf (patch)
treea072ea398ce00b68dd0e5e670b32ac5ee1a812ad /src/modules/utils.js
parent263201d869956b94660d4efa8297e89dadbe36a8 (diff)
Use CSS transformations instead of manipulating the viewBox
Diffstat (limited to 'src/modules/utils.js')
-rw-r--r--src/modules/utils.js8
1 files changed, 8 insertions, 0 deletions
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);
+}