added setAttrs() method back in because I realized that it wasn't hurting performance that much

This commit is contained in:
Eric Rowell 2012-10-28 22:45:37 -07:00
parent fb90709b3a
commit d0ebbc939a
4 changed files with 18 additions and 18 deletions

View File

@ -1 +1 @@
Kinetic.Transition=function(a,b){function d(a,b,e){for(var f in a)f!=="duration"&&f!=="easing"&&f!=="callback"&&(Kinetic.Type._isObject(a[f])?(e[f]={},d(a[f],b[f],e[f])):c._add(c._getTween(b,f,a[f],e)))}this.node=a,this.config=b,this.tweens=[];var c=this,e={};d(b,a.attrs,e);var f=0;for(var g=0;g<this.tweens.length;g++){var h=this.tweens[g];h.onFinished=function(){f++,f>=c.tweens.length&&c.onFinished()}}},Kinetic.Transition.prototype={start:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].start()},stop:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].stop()},resume:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].resume()},_onEnterFrame:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].onEnterFrame()},_add:function(a){this.tweens.push(a)},_getTween:function(a,b,c,d){var e=this.config,f=this.node,g=e.easing;g===undefined&&(g="linear");var h=new Kinetic.Tween(f,function(a){d[b]=a,f.attrs[b]=a},Kinetic.Tweens[g],a[b],c,e.duration);return h}},Kinetic.Node.prototype.transitionTo=function(a){this.transAnim||(this.transAnim=new Kinetic.Animation);var b=this.nodeType==="Stage"?this:this.getLayer(),c=this,d=new Kinetic.Transition(this,a);return this.transAnim.func=function(){d._onEnterFrame()},this.transAnim.node=b,d.onFinished=function(){c.transAnim.stop(),a.callback&&a.callback()},d.start(),this.transAnim.start(),d};
Kinetic.Transition=function(a,b){function d(a,b,e,f){for(var g in a)g!=="duration"&&g!=="easing"&&g!=="callback"&&(Kinetic.Type._isObject(a[g])?(e[g]={},d(a[g],b[g],e[g],f)):c._add(c._getTween(b,g,a[g],e,f)))}this.node=a,this.config=b,this.tweens=[];var c=this,e={};d(b,a.attrs,e,e);var f=0;for(var g=0;g<this.tweens.length;g++){var h=this.tweens[g];h.onFinished=function(){f++,f>=c.tweens.length&&c.onFinished()}}},Kinetic.Transition.prototype={start:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].start()},stop:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].stop()},resume:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].resume()},_onEnterFrame:function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].onEnterFrame()},_add:function(a){this.tweens.push(a)},_getTween:function(a,b,c,d,e){var f=this.config,g=this.node,h=f.easing;h===undefined&&(h="linear");var i=new Kinetic.Tween(g,function(a){d[b]=a,g.setAttrs(e)},Kinetic.Tweens[h],a[b],c,f.duration);return i}},Kinetic.Node.prototype.transitionTo=function(a){this.transAnim||(this.transAnim=new Kinetic.Animation);var b=this.nodeType==="Stage"?this:this.getLayer(),c=this,d=new Kinetic.Transition(this,a);return this.transAnim.func=function(){d._onEnterFrame()},this.transAnim.node=b,d.onFinished=function(){c.transAnim.stop(),a.callback&&a.callback()},d.start(),this.transAnim.start(),d};

View File

@ -2412,22 +2412,22 @@ Kinetic.Transition = function(node, config) {
var that = this;
// add tween for each property
function addTween(c, attrs, obj) {
function addTween(c, attrs, obj, rootObj) {
for(var key in c) {
if(key !== 'duration' && key !== 'easing' && key !== 'callback') {
// if val is an object then traverse
if(Kinetic.Type._isObject(c[key])) {
obj[key] = {};
addTween(c[key], attrs[key], obj[key]);
addTween(c[key], attrs[key], obj[key], rootObj);
}
else {
that._add(that._getTween(attrs, key, c[key], obj));
that._add(that._getTween(attrs, key, c[key], obj, rootObj));
}
}
}
}
var obj = {};
addTween(config, node.attrs, obj);
addTween(config, node.attrs, obj, obj);
var finishedTweens = 0;
for(var n = 0; n < this.tweens.length; n++) {
@ -2482,7 +2482,7 @@ Kinetic.Transition.prototype = {
_add: function(tween) {
this.tweens.push(tween);
},
_getTween: function(attrs, prop, val, obj) {
_getTween: function(attrs, prop, val, obj, rootObj) {
var config = this.config;
var node = this.node;
var easing = config.easing;
@ -2492,7 +2492,7 @@ Kinetic.Transition.prototype = {
var tween = new Kinetic.Tween(node, function(i) {
obj[prop] = i;
node.attrs[prop] = i;
node.setAttrs(rootObj);
}, Kinetic.Tweens[easing], attrs[prop], val, config.duration);
return tween;
@ -2535,7 +2535,7 @@ Kinetic.Node.prototype.transitionTo = function(config) {
trans.onFinished = function() {
// remove animation
that.transAnim.stop();
// callback
if(config.callback) {
config.callback();

File diff suppressed because one or more lines are too long

View File

@ -11,22 +11,22 @@ Kinetic.Transition = function(node, config) {
var that = this;
// add tween for each property
function addTween(c, attrs, obj) {
function addTween(c, attrs, obj, rootObj) {
for(var key in c) {
if(key !== 'duration' && key !== 'easing' && key !== 'callback') {
// if val is an object then traverse
if(Kinetic.Type._isObject(c[key])) {
obj[key] = {};
addTween(c[key], attrs[key], obj[key]);
addTween(c[key], attrs[key], obj[key], rootObj);
}
else {
that._add(that._getTween(attrs, key, c[key], obj));
that._add(that._getTween(attrs, key, c[key], obj, rootObj));
}
}
}
}
var obj = {};
addTween(config, node.attrs, obj);
addTween(config, node.attrs, obj, obj);
var finishedTweens = 0;
for(var n = 0; n < this.tweens.length; n++) {
@ -81,7 +81,7 @@ Kinetic.Transition.prototype = {
_add: function(tween) {
this.tweens.push(tween);
},
_getTween: function(attrs, prop, val, obj) {
_getTween: function(attrs, prop, val, obj, rootObj) {
var config = this.config;
var node = this.node;
var easing = config.easing;
@ -91,7 +91,7 @@ Kinetic.Transition.prototype = {
var tween = new Kinetic.Tween(node, function(i) {
obj[prop] = i;
node.attrs[prop] = i;
node.setAttrs(rootObj);
}, Kinetic.Tweens[easing], attrs[prop], val, config.duration);
return tween;
@ -134,7 +134,7 @@ Kinetic.Node.prototype.transitionTo = function(config) {
trans.onFinished = function() {
// remove animation
that.transAnim.stop();
// callback
if(config.callback) {
config.callback();