2013-05-21 13:41:13 +08:00
|
|
|
Test.Modules.TWEEN = {
|
|
|
|
'tween node': function(containerId) {
|
|
|
|
var stage = new Kinetic.Stage({
|
|
|
|
container: containerId,
|
|
|
|
width: 578,
|
|
|
|
height: 200
|
|
|
|
});
|
|
|
|
|
|
|
|
var layer = new Kinetic.Layer();
|
|
|
|
|
|
|
|
var circle = new Kinetic.Circle({
|
|
|
|
x: 100,
|
|
|
|
y: stage.getHeight() / 2,
|
|
|
|
radius: 70,
|
|
|
|
fill: 'green',
|
2013-06-07 12:56:40 +08:00
|
|
|
stroke: 'blue',
|
2013-05-21 13:41:13 +08:00
|
|
|
strokeWidth: 4
|
|
|
|
});
|
|
|
|
|
|
|
|
layer.add(circle);
|
|
|
|
stage.add(layer);
|
|
|
|
|
|
|
|
var finishCount = 0;
|
|
|
|
var onFinish = function() {
|
|
|
|
test(++finishCount <= 1, 'finishCount should not exceed 1');
|
|
|
|
}
|
|
|
|
|
2013-06-05 13:39:11 +08:00
|
|
|
var tweens = 0;
|
|
|
|
var attrs = 0;
|
|
|
|
|
|
|
|
for (var key in Kinetic.Tween.tweens) {
|
|
|
|
tweens++;
|
|
|
|
}
|
|
|
|
for (var key in Kinetic.Tween.attrs) {
|
|
|
|
attrs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
test(tweens === 0, 'should be no tweens');
|
|
|
|
test(attrs === 0, 'should be no attrs');
|
|
|
|
|
2013-05-21 13:41:13 +08:00
|
|
|
var tween = new Kinetic.Tween({
|
|
|
|
node: circle,
|
|
|
|
duration: 0.2,
|
|
|
|
x: 200,
|
|
|
|
y: 100,
|
|
|
|
onFinish: onFinish
|
|
|
|
}).play();
|
|
|
|
|
2013-06-05 13:39:11 +08:00
|
|
|
var tweens = 0;
|
|
|
|
var attrs = 0;
|
|
|
|
for (var key in Kinetic.Tween.tweens) {
|
|
|
|
tweens++;
|
|
|
|
}
|
|
|
|
for (var key in Kinetic.Tween.attrs[circle._id][tween._id]) {
|
|
|
|
attrs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
test(tweens === 1, 'should one tween');
|
|
|
|
test(attrs === 2, 'should two attrs');
|
|
|
|
|
|
|
|
test(Kinetic.Tween.attrs[circle._id][tween._id].x !== undefined, 'x should not be undefined');
|
|
|
|
test(Kinetic.Tween.attrs[circle._id][tween._id].y !== undefined, 'y should not be undefined');
|
|
|
|
|
2013-05-21 13:41:13 +08:00
|
|
|
}
|
|
|
|
};
|