-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfromMatrix.js
35 lines (26 loc) · 1.04 KB
/
fromMatrix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var checkIsCrappyIE = require('./lib/checkIsCrappyIE');
var applyMatrix = require('./lib/applyMatrix');
var applyTransformOrigin = require('./lib/applyTransformOrigin');
module.exports = function ieCSSTransformFromMatrix(el, matrix, transformOrigin) {
var matrixString;
var perspective;
if(checkIsCrappyIE(el)) {
applyMatrix(el, matrix, transformOrigin);
} else {
matrixString = Array.prototype.join.call(matrix, ',');
if(matrix.length === 6) {
el.style.transform = 'matrix(' + matrixString + ')';
} else {
perspective = matrix[ 11 ];
// the following is done because it seems like webkit does not render
// the matrix perspective value correctly
if(perspective) {
perspective = -1 / perspective;
el.style.transform = 'perspective(' + perspective + 'px) matrix3d(' + matrixString + ')';
} else {
el.style.transform = 'matrix3d(' + matrixString + ')';
}
}
applyTransformOrigin(el, transformOrigin);
}
};