Skip to content

Commit

Permalink
fix: Defer the saving of starting values until '.start()'.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebolt committed Dec 23, 2016
1 parent 03209e9 commit bfb739b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/Tween.js
Expand Up @@ -124,18 +124,10 @@ TWEEN.Tween = function (object) {

this.to = function (properties, duration) {

if (duration !== undefined) {
_duration = duration;
}

_valuesEnd = properties;

// Set all starting values present on the target object
for (var field in _valuesEnd) {
// Only add to updateables if tweenable object has the field
if (typeof _object[field] !== 'undefined') {
_valuesStart[field] = parseFloat(_object[field], 10);
}
if (duration !== undefined) {
_duration = duration;
}

return this;
Expand Down Expand Up @@ -173,6 +165,7 @@ TWEEN.Tween = function (object) {
continue;
}

// Save the starting value.
_valuesStart[property] = _object[property];

if ((_valuesStart[property] instanceof Array) === false) {
Expand Down

0 comments on commit bfb739b

Please sign in to comment.