tween.js icon indicating copy to clipboard operation
tween.js copied to clipboard

Add : tests for onRepeat callback

Open MasatoMakino opened this issue 3 years ago • 0 comments

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.

  1. TWEEN.Tween.onRepeat should not be called if repeat = 0 or default
  2. TWEEN.Tween.onRepeat should be called once if repeat = 1
  3. TWEEN.Tween.onRepeat should be called every time if repeat = Infinity
  4. TWEEN.Tween.onRepeat should not be called if Tween.pause() or Tween.stop(), and should be called after Tween.resume() or restart
  5. If Tween.delay is set, TWEEN.Tween.onRepeat should be called when repeat section finished
  6. 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.

MasatoMakino avatar May 02 '21 09:05 MasatoMakino