Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS acceleration #9

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 <[email protected]>
Expand Down Expand Up @@ -180,6 +179,7 @@
this._props = {};
this._rotate = 0;
this._transitionProps = [];
this._webkitTransforms = [];
this._transforms = [];
this.duration(move.defaults.duration)
};
Expand All @@ -200,6 +200,7 @@
*/

Move.prototype.transform = function(transform){
this._webkitTransforms.push(transform);
this._transforms.push(transform);
return this;
};
Expand Down Expand Up @@ -254,11 +255,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 @@ -271,7 +274,7 @@

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

/**
Expand All @@ -284,7 +287,7 @@

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

/**
Expand All @@ -297,11 +300,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 @@ -313,7 +318,7 @@
*/

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

/**
Expand All @@ -325,7 +330,7 @@
*/

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

/**
Expand Down Expand Up @@ -431,8 +436,10 @@
* @api public
*/

Move.prototype.setVendorProperty = function(prop, val){
this.setProperty('-webkit-' + prop, val);
Move.prototype.setVendorProperty = function(prop, val, options){
if (!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 @@ -614,7 +621,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.