Skip to content

Commit 46ff0a1

Browse files
author
Dennis Hergaarden
committed
Break on unequal list and better variable naming
1 parent 31a2fc6 commit 46ff0a1

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/tweenjs/plugins/CSSPlugin.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ this.createjs = this.createjs || {};
235235
if (compare[1][i].constructor !== result[i].constructor) {
236236
console.log("transforms don't match: ", result[0].constructor.name, compare[1][i].constructor.name);
237237
compare = null;
238+
break;
238239
} // component doesn't match
239240
}
240241
}
@@ -250,36 +251,36 @@ this.createjs = this.createjs || {};
250251
if (ratio === 0 || !list1[0]) { return list0[1].toString(); }
251252

252253
// they match, we want to apply the ratio:
253-
let original = list0[1];
254-
let modifiedValue = CSSStyleValue.parse("transform", original.toString());
255-
let newValue = list1[1];
254+
let startValue = list0[1];
255+
let newValue = CSSStyleValue.parse("transform", startValue.toString());
256+
let endValue = list1[1];
256257

257258
// Only works for rotate, scale and translate, skew or metrix do not have x,y,z
258-
for (let i = 0; i < original.length; i++) {
259-
switch (original[i].constructor) {
259+
for (let i = 0; i < startValue.length; i++) {
260+
switch (startValue[i].constructor) {
260261
case CSSRotate:
261-
modifiedValue[i].angle.value += (newValue[i].angle.value - original[i].angle.value) * ratio;
262+
newValue[i].angle.value += (endValue[i].angle.value - startValue[i].angle.value) * ratio;
262263
// Fall down to CSSScale to set x,y,z
263264
case CSSTranslate:
264265
// Fall down to CSSScale to set x,y,z
265266
case CSSScale:
266-
modifiedValue[i].x.value += (newValue[i].x.value - original[i].x.value) * ratio;
267-
modifiedValue[i].y.value += (newValue[i].y.value - original[i].y.value) * ratio;
268-
modifiedValue[i].z.value += (newValue[i].z.value - original[i].z.value) * ratio;
267+
newValue[i].x.value += (endValue[i].x.value - startValue[i].x.value) * ratio;
268+
newValue[i].y.value += (endValue[i].y.value - startValue[i].y.value) * ratio;
269+
newValue[i].z.value += (endValue[i].z.value - startValue[i].z.value) * ratio;
269270
break;
270271
case CSSSkew:
271-
modifiedValue[i].ax.value += (newValue[i].ax.value - original[i].ax.value) * ratio;
272-
modifiedValue[i].ay.value += (newValue[i].ay.value - original[i].ay.value) * ratio;
272+
newValue[i].ax.value += (endValue[i].ax.value - startValue[i].ax.value) * ratio;
273+
newValue[i].ay.value += (endValue[i].ay.value - startValue[i].ay.value) * ratio;
273274
break;
274275
case CSSSkewX:
275-
modifiedValue[i].ax.value += (newValue[i].ax.value - original[i].ax.value) * ratio;
276+
newValue[i].ax.value += (endValue[i].ax.value - startValue[i].ax.value) * ratio;
276277
break;
277278
case CSSSkewY:
278-
modifiedValue[i].ay.value += (newValue[i].ay.value - original[i].ay.value) * ratio;
279+
newValue[i].ay.value += (endValue[i].ay.value - startValue[i].ay.value) * ratio;
279280
break;
280281
}
281282
}
282-
return modifiedValue.toString();
283+
return newValue.toString();
283284
}
284285

285286
createjs.CSSPlugin = s;

0 commit comments

Comments
 (0)