added new animation stop logic

This commit is contained in:
Eric Rowell
2012-04-03 13:44:48 -07:00
parent fc5825e61e
commit a6b526ee76
2 changed files with 24 additions and 9 deletions

View File

@@ -54,6 +54,8 @@ Kinetic.Stage = function(config) {
this._listen();
this._prepareDrag();
this.anim = undefined;
// add stage to global object
Kinetic.GlobalObject.stages.push(this);
@@ -71,22 +73,26 @@ Kinetic.Stage.prototype = {
*/
onFrame: function(func) {
var go = Kinetic.GlobalObject;
go.addAnimation({
this.anim = {
id: go.animIdCounter++,
func: func
});
};
},
/**
* start animation
*/
start: function() {
Kinetic.GlobalObject._handleAnimation();
var go = Kinetic.GlobalObject;
go.addAnimation(this.anim);
go._handleAnimation();
},
/**
* stop animation
*/
stop: function() {
Kinetic.GlobalObject._handleAnimation();
var go = Kinetic.GlobalObject;
go.removeAnimation(this.anim.id);
go._handleAnimation();
},
/**
* draw children