mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
fixed clear transition bug
This commit is contained in:
@@ -42,7 +42,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;
|
||||
}
|
||||
}
|
||||
@@ -136,20 +136,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++) {
|
||||
@@ -171,7 +164,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();
|
||||
}
|
||||
|
@@ -16,7 +16,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, []);
|
||||
@@ -78,10 +77,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);
|
||||
}
|
||||
}
|
||||
|
@@ -455,7 +455,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') {
|
||||
@@ -483,7 +483,6 @@ Kinetic.Node.prototype = {
|
||||
starts: starts
|
||||
});
|
||||
|
||||
layer.isTransitioning = true;
|
||||
Kinetic.GlobalObject._handleAnimation();
|
||||
},
|
||||
/**
|
||||
|
Reference in New Issue
Block a user