mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 04:14:52 +08:00
fixed #460
This commit is contained in:
4
Thorfile
4
Thorfile
@@ -13,6 +13,7 @@ class Build < Thor
|
||||
|
||||
UNIT_TESTS = [
|
||||
"tests/js/unit/animationTests.js",
|
||||
"tests/js/unit/tweenTests.js",
|
||||
"tests/js/unit/globalTests.js",
|
||||
"tests/js/unit/utilTests.js",
|
||||
"tests/js/unit/nodeTests.js",
|
||||
@@ -35,8 +36,7 @@ class Build < Thor
|
||||
"tests/js/unit/plugins/pathTests.js",
|
||||
"tests/js/unit/plugins/regularPolygonTests.js",
|
||||
"tests/js/unit/plugins/starTests.js",
|
||||
"tests/js/unit/plugins/textPathTests.js",
|
||||
"tests/js/unit/plugins/labelTests.js"
|
||||
"tests/js/unit/plugins/textPathTests.js"
|
||||
]
|
||||
|
||||
if !File.directory?("dist")
|
||||
|
21
src/Tween.js
21
src/Tween.js
@@ -94,23 +94,36 @@
|
||||
tween = tweens[n];
|
||||
}
|
||||
},
|
||||
_isLastTween: function(tween) {
|
||||
var tweens = this.tweens,
|
||||
len = tweens.length,
|
||||
n;
|
||||
|
||||
return tweens[len - 1].prop === tween.prop;
|
||||
},
|
||||
_addListeners: function(tween) {
|
||||
var that = this;
|
||||
|
||||
// start listeners
|
||||
tween.onPlay = function() {
|
||||
that.anim.start();
|
||||
if (that._isLastTween(tween)) {
|
||||
that.anim.start();
|
||||
}
|
||||
};
|
||||
tween.onReverse = function() {
|
||||
that.anim.start();
|
||||
if (that._isLastTween(tween)) {
|
||||
that.anim.start();
|
||||
}
|
||||
};
|
||||
|
||||
// stop listeners
|
||||
tween.onPause = function() {
|
||||
that.anim.stop();
|
||||
if (that._isLastTween(tween)) {
|
||||
that.anim.stop();
|
||||
}
|
||||
};
|
||||
tween.onFinish = function() {
|
||||
if (that.onFinish) {
|
||||
if (that._isLastTween(tween) && that.onFinish) {
|
||||
that.onFinish();
|
||||
}
|
||||
};
|
||||
|
37
tests/js/unit/tweenTests.js
Normal file
37
tests/js/unit/tweenTests.js
Normal file
@@ -0,0 +1,37 @@
|
||||
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',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4
|
||||
});
|
||||
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
|
||||
var finishCount = 0;
|
||||
var onFinish = function() {
|
||||
test(++finishCount <= 1, 'finishCount should not exceed 1');
|
||||
}
|
||||
|
||||
var tween = new Kinetic.Tween({
|
||||
node: circle,
|
||||
duration: 0.2,
|
||||
x: 200,
|
||||
y: 100,
|
||||
onFinish: onFinish
|
||||
}).play();
|
||||
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user