3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
11 var Declaration = require('../declaration');
13 var TransformDecl = function (_Declaration) {
14 _inherits(TransformDecl, _Declaration);
16 function TransformDecl() {
17 _classCallCheck(this, TransformDecl);
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
23 * Recursively check all parents for @keyframes
25 TransformDecl.prototype.keyframeParents = function keyframeParents(decl) {
26 var parent = decl.parent;
29 if (parent.type === 'atrule' && parent.name === 'keyframes') {
33 parent = _parent.parent;
39 * Is transform contain 3D commands
43 TransformDecl.prototype.contain3d = function contain3d(decl) {
44 if (decl.prop === 'transform-origin') {
48 for (var _iterator = TransformDecl.functions3d, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
52 if (_i >= _iterator.length) break;
53 _ref = _iterator[_i++];
55 _i = _iterator.next();
62 if (decl.value.indexOf(func + '(') !== -1) {
71 * Replace rotateZ to rotate for IE 9
75 TransformDecl.prototype.set = function set(decl, prefix) {
76 decl = _Declaration.prototype.set.call(this, decl, prefix);
77 if (prefix === '-ms-') {
78 decl.value = decl.value.replace(/rotateZ/gi, 'rotate');
84 * Don't add prefix for IE in keyframes
88 TransformDecl.prototype.insert = function insert(decl, prefix, prefixes) {
89 if (prefix === '-ms-') {
90 if (!this.contain3d(decl) && !this.keyframeParents(decl)) {
91 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
93 } else if (prefix === '-o-') {
94 if (!this.contain3d(decl)) {
95 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
98 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
103 return TransformDecl;
106 Object.defineProperty(TransformDecl, 'names', {
109 value: ['transform', 'transform-origin']
111 Object.defineProperty(TransformDecl, 'functions3d', {
114 value: ['matrix3d', 'translate3d', 'translateZ', 'scale3d', 'scaleZ', 'rotate3d', 'rotateX', 'rotateY', 'perspective']
118 module.exports = TransformDecl;