Skip to content

Commit 28a9178

Browse files
committed
remove dirty matrix validation - take care of matrix3d form instead
1 parent 29e772d commit 28a9178

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/lib/dom.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,13 @@ function getElementTransformMatrix(element) {
126126
);
127127

128128
if(transform === 'none') return null;
129-
// the slice is because the transform string returns eg "matrix(0.5, 0, 1, 0, 1, 1)"
130-
return transform.slice(7, -1).split(',').map(function(n) {return +n;});
129+
// the transform is a string in the form of matrix(a, b, ...) or matrix3d(...)
130+
return transform
131+
.replace('matrix', '')
132+
.replace('3d', '')
133+
.slice(1, -1)
134+
.split(',')
135+
.map(function(n) { return +n; });
131136
}
132137
/**
133138
* retrieve all DOM elements that are ancestors of the specified one (including itself)

src/lib/matrix.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,7 @@ exports.apply2DTransform2 = function(transform) {
118118
exports.convertCssMatrix = function(m) {
119119
if(m) {
120120
var len = m.length;
121-
if(len === 16) {
122-
// validate values
123-
return [
124-
m[0] || 1, m[1] || 0, m[2] || 0, m[3] || 0,
125-
m[4] || 0, m[5] || 1, m[6] || 0, m[7] || 0,
126-
m[8] || 0, m[9] || 0, m[10] || 1, m[11] || 0,
127-
m[12] || 0, m[13] || 0, m[14] || 0, m[15] || 1
128-
];
129-
}
121+
if(len === 16) return m;
130122
if(len === 6) {
131123
// converts a 2x3 css transform matrix to a 4x4 matrix see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
132124
return [

0 commit comments

Comments
 (0)