tween.js
tween.js copied to clipboard
Add : tests for onRepeat callback
Related Issues
- Add a test for onRepeat #456
- Implement onBeforeRepeat #290
Purpose of this Pull Request
This PR is to add tests for the Tween.onRepeat callback.
Details of the changes
I add the following tests. This test follows current onRepeat implementation.
- TWEEN.Tween.onRepeat should not be called if repeat = 0 or default
- TWEEN.Tween.onRepeat should be called once if repeat = 1
- TWEEN.Tween.onRepeat should be called every time if repeat = Infinity
- TWEEN.Tween.onRepeat should not be called if Tween.pause() or Tween.stop(), and should be called after Tween.resume() or restart
- If Tween.delay is set, TWEEN.Tween.onRepeat should be called when repeat section finished
- If Tween.repeatDelay is set, TWEEN.Tween.onRepeat should be called when repeat section finished
Confirmation
I found that onRepeat behaves differently from GSAP. This difference appears when we set delay or repeatDelay.
GSAP : onRepeat is called just before the tween finishes, waits for a delay, and then plays the next repeat. tween.js : onRepeat is called just after the tween finishes, before waiting for the delay.
onRepeat by gsap onRepeat by tween.js
I wrote a codepen on this confirmation. Repeat count on the screen is increased by onRepeat. You can see that the timing at which the repeat count changes is different for each sample.
Is this difference as per specifications? Or is it a bug? I will keep this PR in draft form until this point is confirmed.