Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebolt committed May 27, 2019
2 parents 76432aa + 1d5686b commit 3a1206f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Expand Up @@ -6,8 +6,12 @@ cache:
notifications:
email: false
node_js:
- node
- "10"
before_install:
- npm i -g npm@^2.0.0
before_script:
- npm prune
script:
- npm run test
after_success:
- npm run semantic-release
6 changes: 6 additions & 0 deletions docs/user_guide.md
Expand Up @@ -373,6 +373,12 @@ Executed when a tween is finished normally (i.e. not stopped).

The tweened object is passed in as the first parameter.

### onRepeat

Executed whenever a tween has just finished one repetition and will begin another.

The tweened object is passed in as the first parameter.

## Advanced tweening

### Relative values
Expand Down
14 changes: 13 additions & 1 deletion src/Tween.js
Expand Up @@ -138,6 +138,7 @@ TWEEN.Tween = function (object, group) {
this._onStartCallback = null;
this._onStartCallbackFired = false;
this._onUpdateCallback = null;
this._onRepeatCallback = null;
this._onCompleteCallback = null;
this._onStopCallback = null;
this._group = group || TWEEN;
Expand Down Expand Up @@ -318,6 +319,13 @@ TWEEN.Tween.prototype = {

},

onRepeat: function onRepeat(callback) {

this._onRepeatCallback = callback;
return this;

},

onComplete: function (callback) {

this._onCompleteCallback = callback;
Expand Down Expand Up @@ -392,7 +400,7 @@ TWEEN.Tween.prototype = {
}

if (this._onUpdateCallback !== null) {
this._onUpdateCallback(this._object);
this._onUpdateCallback(this._object, elapsed);
}

if (elapsed === 1) {
Expand Down Expand Up @@ -431,6 +439,10 @@ TWEEN.Tween.prototype = {
this._startTime = time + this._delayTime;
}

if (this._onRepeatCallback !== null) {
this._onRepeatCallback(this._object);
}

return true;

} else {
Expand Down

0 comments on commit 3a1206f

Please sign in to comment.