stage tweens now work correctly. getChildren() and getLayers() now return a Kinetic.Collection. added toArray() method to Kinetic.Collection

This commit is contained in:
Eric Rowell
2013-05-19 21:07:43 -07:00
parent 056346c14d
commit 7069bf9e0c
8 changed files with 78 additions and 33 deletions

View File

@@ -423,12 +423,12 @@ Test.Modules.EVENT = {
layer.on('draw', function(evt) {
savedEvt = evt;
eventNodes.push(this.getNodeType());
eventNodes.push(this.getType());
order.push('layer draw');
});
stage.on('draw', function(evt) {
eventNodes.push(this.getNodeType());
eventNodes.push(this.getType());
order.push('stage draw');
});
@@ -447,7 +447,7 @@ Test.Modules.EVENT = {
// Note: draw events no longer bubble
//test(eventNodes.toString() === 'Layer,Stage', 'layer draw event should have fired followed by stage draw event');
test(savedEvt.node.getNodeType() === 'Layer', 'event object should contain a node property which is Layer');
test(savedEvt.node.getType() === 'Layer', 'event object should contain a node property which is Layer');
//test(order.toString() === 'layer beforeDraw,stage beforeDraw,layer draw,stage draw', 'order should be: layer beforeDraw,stage beforeDraw,layer draw,stage draw');

View File

@@ -1,4 +1,4 @@
Test.Modules.TRANSITION = {
Test.Modules.Tween = {
'!transition position and rotation': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
@@ -213,21 +213,50 @@ Test.Modules.TRANSITION = {
tween.play();
/*
var tween2 = new Kinetic.Tween({
node: greenBox,
duration: 2,
x: 200,
easing: Kinetic.Easings.BounceEaseOut,
});
tween2.play();
*/
document.getElementById(containerId).addEventListener('click', function() {
tween.seek(1.5);
tween.reverse();
});
},
'tween stage': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var greenBox = new Kinetic.Rect({
x: 50,
y: stage.getHeight() / 2 - 25,
width: 100,
height: 50,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
offset: {
x: 50,
y: 25
}
});
layer.add(greenBox);
stage.add(layer);
var tween = new Kinetic.Tween({
node: stage,
duration: 2,
x: 400,
scaleX: 2,
scaleY: 2,
easing: Kinetic.Easings.BounceEaseOut,
yoyo: false,
onFinish: function() {
console.log('finished!')
}
});
tween.play();
}
};