fixed transition bug related to frame.timeDiff

This commit is contained in:
Eric Rowell 2012-03-19 19:39:41 -07:00
parent 70fe63b2b6
commit 588b65a849
4 changed files with 52 additions and 18 deletions

View File

@ -3,7 +3,7 @@
* http://www.kineticjs.com/ * http://www.kineticjs.com/
* Copyright 2012, Eric Rowell * Copyright 2012, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses. * Licensed under the MIT or GPL Version 2 licenses.
* Date: Mar 18 2012 * Date: Mar 19 2012
* *
* Copyright (C) 2011 - 2012 by Eric Rowell * Copyright (C) 2011 - 2012 by Eric Rowell
* *
@ -75,6 +75,8 @@ Kinetic.GlobalObject = {
} }
} }
} }
this.frame.lastTime = 0;
return false; return false;
}, },
_endTransition: function() { _endTransition: function() {
@ -196,9 +198,6 @@ Kinetic.GlobalObject = {
if(this._isaCanvasAnimating()) { if(this._isaCanvasAnimating()) {
that._animationLoop(); that._animationLoop();
} }
else {
this.frame.lastTime = 0;
}
} }
}; };

File diff suppressed because one or more lines are too long

View File

@ -47,6 +47,8 @@ Kinetic.GlobalObject = {
} }
} }
} }
this.frame.lastTime = 0;
return false; return false;
}, },
_endTransition: function() { _endTransition: function() {
@ -168,9 +170,6 @@ Kinetic.GlobalObject = {
if(this._isaCanvasAnimating()) { if(this._isaCanvasAnimating()) {
that._animationLoop(); that._animationLoop();
} }
else {
this.frame.lastTime = 0;
}
} }
}; };

View File

@ -78,9 +78,50 @@ Test.prototype.tests = {
stage.start(); stage.start();
setTimeout(function() { setTimeout(function() {
stage.stop(); stage.stop();
}, 1000); }, 1000);
}, },
'TRANSITION - hover transition': function(containerId) {
var stage = new Kinetic.Stage(containerId, 578, 200);
var layer = new Kinetic.Layer();
var rect = new Kinetic.Rect({
x: stage.width / 2 - 50,
y: stage.height / 2 - 25,
width: 100,
height: 50,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
centerOffset: {
x: 50,
y: 25
}
});
rect.on("mouseover", function() {
this.transitionTo({
scale: {
x: 1.3,
y: 1.3
},
duration: 0.3
});
});
rect.on("mouseout", function() {
this.transitionTo({
scale: {
x: 1,
y: 1
},
duration: 0.3
});
});
layer.add(rect);
stage.add(layer);
},
'EVENTS - mousedown mouseup mouseover mouseout click dblclick / touchstart touchend dbltap': function(containerId) { 'EVENTS - mousedown mouseup mouseover mouseout click dblclick / touchstart touchend dbltap': function(containerId) {
var stage = new Kinetic.Stage(containerId, 578, 200); var stage = new Kinetic.Stage(containerId, 578, 200);
var layer = new Kinetic.Layer(); var layer = new Kinetic.Layer();
@ -467,13 +508,10 @@ Test.prototype.tests = {
var layer = new Kinetic.Layer(); var layer = new Kinetic.Layer();
var group = new Kinetic.Group(); var group = new Kinetic.Group();
group.on('click', function() { group.on('click', function() {
log('click group'); log('click group');
//console.log(this); //console.log(this);
}); });
var redCircle = new Kinetic.Circle({ var redCircle = new Kinetic.Circle({
x: stage.width / 2, x: stage.width / 2,
y: stage.height / 2, y: stage.height / 2,
@ -509,7 +547,6 @@ Test.prototype.tests = {
log('mousemove group'); log('mousemove group');
//console.log(this); //console.log(this);
}); });
var redCircle = new Kinetic.Circle({ var redCircle = new Kinetic.Circle({
x: stage.width / 2, x: stage.width / 2,
y: stage.height / 2, y: stage.height / 2,
@ -538,7 +575,7 @@ Test.prototype.tests = {
var stage = new Kinetic.Stage(containerId, 578, 200); var stage = new Kinetic.Stage(containerId, 578, 200);
var layer = new Kinetic.Layer(); var layer = new Kinetic.Layer();
var group = new Kinetic.Group({ var group = new Kinetic.Group({
name: 'group' name: 'group'
}); });
group.on('mouseover', function() { group.on('mouseover', function() {
@ -548,7 +585,6 @@ Test.prototype.tests = {
group.on('mouseout', function() { group.on('mouseout', function() {
log('mouseout group'); log('mouseout group');
}); });
var redCircle = new Kinetic.Circle({ var redCircle = new Kinetic.Circle({
x: stage.width / 2, x: stage.width / 2,
y: stage.height / 2, y: stage.height / 2,