Skip to content

Commit 8c1ef52

Browse files
committed
bug fix for multiple scenes
1 parent ee371c3 commit 8c1ef52

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

jquery.data-parallax.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
animation.rotate = new Scene($this, rotateOptions, 360);
106106
}
107107
if (animation.x || animation.y || animation.z || animation.scale || animation.rotate) {
108-
animation.transform = new Transform(new TransformMatrix());
108+
animation.transform = true;
109109
}
110110

111111
if (typeof options.color != "undefined") {
@@ -159,7 +159,7 @@
159159
for (var i=0, len=animations.length; i<len; i++) {
160160
animation = animations[i];
161161
if (animation.transform) {
162-
TransformMatrix.fromStyle(style, animation.transform.matrix);
162+
animation.transform = new Transform(TransformMatrix.fromStyle(style));
163163
if (animation.x && animation.x.needsUpdate()) {
164164
var newX = animation.x.getValue(animation.transform.matrix.getTranslateX());
165165
animation.transform.setTranslateX(newX);
@@ -180,12 +180,14 @@
180180
var newRotation = animation.rotate.getValue(animation.transform.matrix.getRotation());
181181
animation.transform.setRotation(newRotation);
182182
}
183-
var transform = animation.transform.toString();
184-
this.style['-webkit-transform'] = transform;
185-
this.style['-moz-transform'] = transform;
186-
this.style['-ms-transform'] = transform;
187-
this.style['-o-transform'] = transform;
188-
this.style.transform = transform;
183+
if (animation.transform.isSet()) {
184+
var transform = animation.transform.toString();
185+
this.style['-webkit-transform'] = transform;
186+
this.style['-moz-transform'] = transform;
187+
this.style['-ms-transform'] = transform;
188+
this.style['-o-transform'] = transform;
189+
this.style.transform = transform;
190+
}
189191
}
190192
if (animation.color && animation.color.needsUpdate()) {
191193
var fromColor = RGBColor.fromString(animation.color.getFrom(style.color)),
@@ -500,6 +502,13 @@
500502
setRotation: function(angle) {
501503
this.rotate = angle;
502504
},
505+
isSet: function() {
506+
return (typeof this.translateX != "undefined" ||
507+
typeof this.translateY != "undefined" ||
508+
typeof this.translateZ != "undefined" ||
509+
typeof this.scale != "undefined" ||
510+
typeof this.rotate != "undefined")
511+
},
503512
toString: function() {
504513
var x = (typeof this.translateX != "undefined" ? this.translateX : this.matrix.getTranslateX()).toFixed(2),
505514
y = (typeof this.translateY != "undefined" ? this.translateY : this.matrix.getTranslateY()).toFixed(2),

0 commit comments

Comments
 (0)