Skip to content

Commit 0a1181d

Browse files
author
daniel-lundin
committed
Detect and use vendor prefixes for transform property
1 parent 32e70d8 commit 0a1181d

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

src/animation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const easing = require('./easing.js');
44
const tweeners = require('./tweeners');
55
const state = require('./state.js');
66

7-
function createAnimation(startState, endState, options) {
7+
function createAnimation(startState, endState, options, transformProperty) {
88
const duration = utils.optionOrDefault(options.duration, 500);
99

1010
const delay = utils.optionOrDefault(options.delay, 0);
@@ -136,7 +136,7 @@ function createAnimation(startState, endState, options) {
136136
return;
137137
var matrix = tweener.asMatrix();
138138
var properties = tweener.getProperties();
139-
utils.updateElementTransform(element, matrix, null, properties.perspective);
139+
utils.updateElementTransform(element, matrix, transformProperty, properties.perspective);
140140
utils.updateElementProperties(element, properties);
141141
}
142142
};

src/engine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const Engine = {
119119
var startState = stateFromOptions(options, previousState, true);
120120
var endState = stateFromOptions(options, previousState, false);
121121

122-
var animation = Animation.createAnimation(startState, endState, options);
122+
var animation = Animation.createAnimation(startState, endState, options, this.transformProperty);
123123
return animation;
124124
},
125125

src/tests/animationTests.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,18 @@ describe('animations', () => {
5959
});
6060
});
6161

62+
describe('updateElement', () => {
63+
const startState = createState({});
64+
const endState = createState({});
65+
66+
it('should use transformProperty passed in constructor', () => {
67+
const element = { style: {} };
68+
const transformProperty = 'webkitTransform';
69+
const animation = createAnimation(startState, endState, {}, transformProperty);
6270

71+
animation.updateElement(element, true);
72+
73+
expect(element.style).to.have.property(transformProperty);
74+
});
75+
});
6376
});

src/utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ function updateElementTransform(element, matrix, transformProperty, perspective)
1717
cssPerspective = 'perspective(' + perspective + 'px) ';
1818
}
1919
var cssMatrix = matrix.asCSS();
20-
//element.style[transformProperty] = cssPerspective + cssMatrix;
21-
element.style.transform = cssPerspective + cssMatrix;
20+
element.style[transformProperty] = cssPerspective + cssMatrix;
2221
}
2322

2423
var updateElementProperties = function(element, properties) {

0 commit comments

Comments
 (0)