added manual test for tween reset event

This commit is contained in:
Eric Rowell
2013-07-21 16:27:40 -07:00
parent 1a85829ccd
commit 217fbf2097
2 changed files with 33 additions and 30 deletions

View File

@@ -25,9 +25,9 @@
* node: node,<br>
* rotationDeg: 360,<br>
* duration: 1,<br>
* easing: Kinetic.Easings.EaseInOut<br>
* easing: Kinetic.Easings.EaseInOut<br>
* });<br><br>
*
*
* // play tween<br>
* tween.play();<br><br>
*
@@ -45,7 +45,6 @@
this.node = node;
this._id = idCounter++;
this.onFinish = config.onFinish;
this.anim = new Kinetic.Animation(function() {
that.tween.onEnterFrame();
@@ -77,8 +76,9 @@
this.reset();
// add Reset event handler after initial reset is fired
this.onReset = config.onReset;
// callbacks
this.onFinish = config.onFinish;
this.onReset = config.onReset;
};
// start/diff object = attrs.nodeId.tweenId.attr
@@ -101,12 +101,12 @@
// add to tween map
start = node.getAttr(key);
if (Kinetic.Util._isArray(end)) {
end = Kinetic.Util._getPoints(end);
diff = [];
len = end.length;
for (n=0; n<len; n++) {
for (n=0; n<len; n++) {
startVal = start[n];
endVal = end[n];
diff.push({
@@ -123,8 +123,8 @@
Kinetic.Tween.attrs[nodeId][this._id][key] = {
start: start,
diff: diff
};
Kinetic.Tween.tweens[nodeId][key] = this._id;
};
Kinetic.Tween.tweens[nodeId][key] = this._id;
},
_tweenFunc: function(i) {
var node = this.node,
@@ -149,9 +149,9 @@
}
}
else {
newVal = start + (diff * i);
newVal = start + (diff * i);
}
node.setAttr(key, newVal);
}
},
@@ -175,8 +175,8 @@
that.onFinish();
}
};
tween.onReset = function() {
if (that._isLastTween(tween) && that.onReset) {
this.tween.onReset = function() {
if (that.onReset) {
that.onReset();
}
};
@@ -372,7 +372,7 @@
}
},
pause: function() {
this.state = PAUSED;
this.state = PAUSED;
this.fire('onPause');
},
getTimer: function() {
@@ -385,7 +385,7 @@
* by Xaric
*/
/**
/**
* @namespace Easings
* @memberof Kinetic
*/

View File

@@ -48,7 +48,7 @@ Test.Modules.Tween = {
});
},
'ease-in, ease-out, ease-in-out hovers': function(containerId) {
'ease-in, ease-out, ease-in-out hovers': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
@@ -66,7 +66,7 @@ Test.Modules.Tween = {
offset: {
x: 50,
y: 25
}
}
});
var blueBox = new Kinetic.Rect({
@@ -110,7 +110,7 @@ Test.Modules.Tween = {
node: greenBox,
scaleX: 1.5,
scaleY: 1.5,
duration: 1,
duration: 1,
easing: Kinetic.Easings.EaseIn
});
@@ -118,7 +118,7 @@ Test.Modules.Tween = {
node: blueBox,
scaleX: 1.5,
scaleY: 1.5,
duration: 1,
duration: 1,
easing: Kinetic.Easings.EaseOut
});
@@ -126,7 +126,7 @@ Test.Modules.Tween = {
node: redBox,
scaleX: 1.5,
scaleY: 1.5,
duration: 1,
duration: 1,
easing: Kinetic.Easings.EaseInOut
});
@@ -137,7 +137,7 @@ Test.Modules.Tween = {
evt.targetNode.tween.reverse();
});
},
'simple tween': function(containerId) {
'*simple tween': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
@@ -171,6 +171,9 @@ Test.Modules.Tween = {
yoyo: false,
onFinish: function() {
console.log('finished!')
},
onReset: function() {
console.log('reset!')
}
});
@@ -182,7 +185,7 @@ Test.Modules.Tween = {
});
tween.play();
tween2.play();
//tween2.play();
document.getElementById(containerId).addEventListener('click', function() {
tween.seek(1.5);
@@ -227,7 +230,7 @@ Test.Modules.Tween = {
});
tween.play();
}
};
@@ -1022,7 +1025,7 @@ Test.Modules.DRAG_AND_DROP = {
layer.add(circle);
stage.add(layer);
circle.on('dragmove', function() {
console.log(this.getLayer().getId());
});
@@ -1391,7 +1394,7 @@ Test.Modules.DRAG_AND_DROP = {
width: 578,
height: 200
});
var bgLayer = new Kinetic.Layer();
var layer = new Kinetic.Layer();
var group = new Kinetic.Group();
@@ -1419,7 +1422,7 @@ Test.Modules.DRAG_AND_DROP = {
group.add(rect);
layer.add(group);
stage.add(bgLayer);
stage.add(layer);
@@ -1427,9 +1430,9 @@ Test.Modules.DRAG_AND_DROP = {
rect.rotate(0.01);
}, layer);
anim.start();
showHit(layer);
var context = bgLayer.getCanvas().getContext();
context.beginPath();
context.moveTo(0, 0);
@@ -1445,7 +1448,7 @@ Test.Modules.DRAG_AND_DROP = {
height: 200
});
var layer = new Kinetic.Layer({
draggable: true
draggable: true
});
var rect = new Kinetic.Rect({
@@ -1457,7 +1460,7 @@ Test.Modules.DRAG_AND_DROP = {
stroke: 'black',
strokeWidth: 4
});
var rect2 = new Kinetic.Rect({
x: 300,
y: 100,