Recently, I've been working with the transform
computed style property.
matrix3d(1.5, -7, 2, 0, 7, 1.5, 0, 0, -3, 1, 1, 0, 100, 0, 0, 1)
Now, my goal is to convert this into an array of numbers:
var s = window.getComputedStyle(element);
var mattrixArray = s.replace(/3d|matrix|(|)|\s|/g,'').split(','), l = mattrixArray.length;
for (var i=0; i<l; i++){
mattrixArray[i] = parseInt(mattrixArray[i],10);
}
console.log(mattrixArray)
The result of this conversion is:
[NaN, -7, 2, 0, 7, 1.5, 0, 0, -3, 1, 1, 0, 100, 0, 0, 1]
However, when I omit parseInt(value)
, it displays correctly but as a string
. How should I proceed?