Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lavrton committed Oct 2, 2014
1 parent 565adc2 commit 362bcf9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
11 changes: 9 additions & 2 deletions kinetic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* http://www.kineticjs.com/
* Copyright 2013, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses.
* Date: 2014-09-24
* Date: 2014-10-02
*
* Copyright (C) 2011 - 2013 by Eric Rowell
*
Expand Down Expand Up @@ -6429,11 +6429,18 @@ var Kinetic = {};
var that = this,
node = config.node,
nodeId = node._id,
duration = config.duration || 1,
duration,
easing = config.easing || Kinetic.Easings.Linear,
yoyo = !!config.yoyo,
key;

if (typeof config.duration === 'undefined') {
duration = 1;
} else if (config.duration === 0) { // zero is bad value for duration
duration = 0.001;
} else {
duration = config.duration;
}
this.node = node;
this._id = idCounter++;

Expand Down
8 changes: 4 additions & 4 deletions kinetic.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/Tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@
var that = this,
node = config.node,
nodeId = node._id,
duration = config.duration || 1,
duration,
easing = config.easing || Kinetic.Easings.Linear,
yoyo = !!config.yoyo,
key;

if (typeof config.duration === 'undefined') {
duration = 1;
} else if (config.duration === 0) { // zero is bad value for duration
duration = 0.001;
} else {
duration = config.duration;
}
this.node = node;
this._id = idCounter++;

Expand Down
38 changes: 38 additions & 0 deletions test/unit/Tween-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,42 @@ suite('Tween', function() {


});

// ======================================================
test('zero duration', function(done) {
var stage = addStage();

var layer = new Kinetic.Layer();

var circle = new Kinetic.Circle({
x: 100,
y: stage.getHeight() / 2,
radius: 70,
fill: 'green',
stroke: 'blue',
strokeWidth: 4
});

layer.add(circle);
stage.add(layer);


var tween = new Kinetic.Tween({
node: circle,
duration: 0,
x: 200,
y: 100
});
tween.play();


setTimeout(function(){
"use strict";
assert.equal(circle.x(), 200);
assert.equal(circle.y(), 100);
done();
}, 60);

});

});

0 comments on commit 362bcf9

Please sign in to comment.