fixed clear transition bug

This commit is contained in:
Eric Rowell
2012-03-20 22:46:54 -07:00
parent bceedc08f6
commit 8aa5fcf560
7 changed files with 98 additions and 40 deletions

29
dist/kinetic-core.js vendored
View File

@@ -3,7 +3,7 @@
* http://www.kineticjs.com/
* Copyright 2012, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses.
* Date: Mar 19 2012
* Date: Mar 20 2012
*
* Copyright (C) 2011 - 2012 by Eric Rowell
*
@@ -70,7 +70,7 @@ Kinetic.GlobalObject = {
for(var i = 0; i < stage.children.length; i++) {
var layer = stage.children[i];
if(layer.isTransitioning) {
if(layer.transitions.length > 0) {
return true;
}
}
@@ -164,20 +164,13 @@ Kinetic.GlobalObject = {
}
}
},
_removeTransition: function(transition) {
var layer = transition.node.getLayer();
var id = transition.id;
_clearTransition: function(node) {
var layer = node.getLayer();
for(var n = 0; n < layer.transitions.length; n++) {
if(layer.transitions[n].id === id) {
layer.transitions.splice(0, 1);
// exit loop
n = layer.transitions.length;
if(layer.transitions[n].node.id === node.id) {
layer.transitions.splice(n, 1);
}
}
if(layer.transitions.length === 0) {
layer.isTransitioning = false;
}
},
_runFrames: function() {
for(var n = 0; n < this.stages.length; n++) {
@@ -199,7 +192,7 @@ Kinetic.GlobalObject = {
transition.time += this.frame.timeDiff;
if(transition.time >= transition.config.duration * 1000) {
this._endTransition.apply(transition);
this._removeTransition(transition);
this._clearTransition(transition.node);
if(transition.config.callback !== undefined) {
transition.config.callback();
}
@@ -709,7 +702,7 @@ Kinetic.Node.prototype = {
* This make it easy to start new transitions without
* having to explicitly cancel old ones
*/
layer._clearTransition(this);
Kinetic.GlobalObject._clearTransition(this);
for(var key in config) {
if(config.hasOwnProperty(key) && key !== 'duration' && key !== 'easing' && key !== 'callback') {
@@ -737,7 +730,6 @@ Kinetic.Node.prototype = {
starts: starts
});
layer.isTransitioning = true;
Kinetic.GlobalObject._handleAnimation();
},
/**
@@ -1655,7 +1647,6 @@ Kinetic.Layer = function(config) {
this.canvas.style.position = 'absolute';
this.transitions = [];
this.transitionIdCounter = 0;
this.isTransitioning = false;
// call super constructors
Kinetic.Container.apply(this, []);
@@ -1717,10 +1708,10 @@ Kinetic.Layer.prototype = {
/**
* clear transition if one is running
*/
_clearTransition: function(shape) {
_clearTransition: function(node) {
for(var n = 0; n < this.transitions.length; n++) {
var transition = this.transitions[n];
if(transition.node.id === shape.id) {
if(transition.node.id === node.id) {
Kinetic.GlobalObject._removeTransition(transition);
}
}

File diff suppressed because one or more lines are too long