Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions move.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*!
* move
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
Expand Down Expand Up @@ -155,6 +154,7 @@
this._props = {};
this._rotate = 0;
this._transitionProps = [];
this._webkitTransforms = [];
this._transforms = [];
this.duration(move.defaults.duration)
};
Expand All @@ -175,6 +175,7 @@
*/

Move.prototype.transform = function(transform){
this._webkitTransforms.push(transform);
this._transforms.push(transform);
return this;
};
Expand Down Expand Up @@ -229,11 +230,13 @@
*/

Move.prototype.translate =
Move.prototype.to = function(x, y){
y = y || 0;
return this.transform('translate('
+ x + 'px, '
+ y + 'px)');
Move.prototype.to = function(x, y, z){
x = this.el._translateX = (x == null ? this.el._translateX : x) || 0;
y = this.el._translateY = (y == null ? this.el._translateY : y) || 0;
z = z || 0;
this._webkitTransforms.push('translate3d('+x+'px, '+y+'px, '+z+')');
this._transforms.push('translate('+x+'px, '+y+'px)');
return this;
};

/**
Expand All @@ -246,7 +249,7 @@

Move.prototype.translateX =
Move.prototype.x = function(n){
return this.transform('translateX(' + n + 'px)');
return this.translate(n, null);
};

/**
Expand All @@ -259,7 +262,7 @@

Move.prototype.translateY =
Move.prototype.y = function(n){
return this.transform('translateY(' + n + 'px)');
return this.translate(null, n);
};

/**
Expand All @@ -272,11 +275,13 @@
* @api public
*/

Move.prototype.scale = function(x, y){
y = null == y ? x : y;
return this.transform('scale('
+ x + ', '
+ y + ')');
Move.prototype.scale = function(x, y, z){
x = this.el._scaleX = (x == null ? this.el._scaleX : x) || 1;
y = y == null ? x : y;
z = z == null ? x : z;
this._webkitTransforms.push('scale3d('+x+', '+y+', '+z+')');
this._transforms.push('scale('+x+', '+y+')');
return this;
};

/**
Expand All @@ -288,7 +293,7 @@
*/

Move.prototype.scaleX = function(n){
return this.transform('scaleX(' + n + ')')
return this.scale(n, null);
};

/**
Expand All @@ -300,7 +305,7 @@
*/

Move.prototype.scaleY = function(n){
return this.transform('scaleY(' + n + ')')
return this.scale(null, n);
};

/**
Expand Down Expand Up @@ -406,8 +411,10 @@
* @api public
*/

Move.prototype.setVendorProperty = function(prop, val){
this.setProperty('-webkit-' + prop, val);
Move.prototype.setVendorProperty = function(prop, val, options){
if ((!options) || (!options.noWebkit)) {
this.setProperty('-webkit-' + prop, val);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options = options || {};
if (!options.noWebkit){

would be easier to read

this.setProperty('-moz-' + prop, val);
this.setProperty('-ms-' + prop, val);
this.setProperty('-o-' + prop, val);
Expand Down Expand Up @@ -589,7 +596,12 @@
this.emit('start');

// transforms
if (this._transforms.length) {
if (this._webkitTransforms.length) {
this.setProperty('-webkit-transform', this._webkitTransforms.join(' '));
this.setVendorProperty('transform', this._transforms.join(' '), { noWebkit: true });
}

else if (this._transforms.length) {
this.setVendorProperty('transform', this._transforms.join(' '));
}

Expand Down
2 changes: 1 addition & 1 deletion move.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.