Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Only converts unit if units are different

Julian Garnierf41dec92ae47
diff --git a/anime.js b/anime.js
index 38dd5a72..8827fba5 100644
--- a/anime.js
+++ b/anime.js
@@ -442,7 +442,7 @@
return el.getAttribute(prop);
}
- function convertCSSUnit(el, value, unit) {
+ function convertPxToUnit(el, value, unit) {
const cached = cache.CSS[value+unit];
if(cached) return cached;
const baseline = 100;
@@ -462,7 +462,7 @@
if (prop in el.style) {
const uppercasePropName = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
const value = el.style[prop] || getComputedStyle(el).getPropertyValue(uppercasePropName) || '0';
- return unit ? convertCSSUnit(el, value, unit) : value;
+ return unit && getUnit(value) !== unit ? convertPxToUnit(el, value, unit) : value;
}
}