kute.js/src/process/getInlineStyleLegacy.js
thednp 933d61de19 Changes:
* added ESLint and updated all code base 
* updated SVGPathCommander, CubicBezier, shorter-js, minifill
* updated polyfills
* minor CSS fixes
2021-03-30 09:23:29 +00:00

25 lines
892 B
JavaScript

import transformProperty from '../util/transformProperty.js';
export default function getInlineStyleLegacy(el) {
if (!el.style) return false; // if the scroll applies to `window` it returns as it has no styling
const css = el.style.cssText.replace(/\s/g, '').split(';'); // the cssText | the resulting transform object
const transformObject = {};
const arrayFn = ['translate3d', 'translate', 'scale3d', 'skew'];
css.forEach((cs) => {
const csi = cs.split(':');
if (csi[0] === transformProperty) {
const tps = csi[1].split(')'); // all transform properties
tps.forEach((tpi) => {
const tpv = tpi.split('('); const tp = tpv[0]; const
tv = tpv[1]; // each transform property
if (!/matrix/.test(tp)) {
transformObject[tp] = arrayFn.includes(tp) ? tv.split(',') : tv;
}
});
}
});
return transformObject;
}