This commit is contained in:
Лаврёнов Антон 2014-10-02 22:28:51 +08:00
parent 565adc2fb6
commit 362bcf9efc
4 changed files with 59 additions and 7 deletions

View File

@ -4,7 +4,7 @@
* http://www.kineticjs.com/ * http://www.kineticjs.com/
* Copyright 2013, Eric Rowell * Copyright 2013, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses. * Licensed under the MIT or GPL Version 2 licenses.
* Date: 2014-09-24 * Date: 2014-10-02
* *
* Copyright (C) 2011 - 2013 by Eric Rowell * Copyright (C) 2011 - 2013 by Eric Rowell
* *
@ -6429,11 +6429,18 @@ var Kinetic = {};
var that = this, var that = this,
node = config.node, node = config.node,
nodeId = node._id, nodeId = node._id,
duration = config.duration || 1, duration,
easing = config.easing || Kinetic.Easings.Linear, easing = config.easing || Kinetic.Easings.Linear,
yoyo = !!config.yoyo, yoyo = !!config.yoyo,
key; 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.node = node;
this._id = idCounter++; this._id = idCounter++;

8
kinetic.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -38,11 +38,18 @@
var that = this, var that = this,
node = config.node, node = config.node,
nodeId = node._id, nodeId = node._id,
duration = config.duration || 1, duration,
easing = config.easing || Kinetic.Easings.Linear, easing = config.easing || Kinetic.Easings.Linear,
yoyo = !!config.yoyo, yoyo = !!config.yoyo,
key; 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.node = node;
this._id = idCounter++; this._id = idCounter++;

View File

@ -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);
});
}); });