Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add : tests for onRepeat callback #609

Conversation

MasatoMakino
Copy link
Contributor

Related Issues

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.

related : Add a test for onRepeat tweenjs#456 , Implement onBeforeRepeat tweenjs#290
@trusktr trusktr changed the base branch from master to main April 23, 2023 19:08
@trusktr
Copy link
Member

trusktr commented Apr 23, 2023

Updated with main

@trusktr trusktr marked this pull request as ready for review April 23, 2023 19:08
@trusktr
Copy link
Member

trusktr commented Apr 23, 2023

Closes #456

@trusktr trusktr linked an issue Apr 23, 2023 that may be closed by this pull request
@trusktr trusktr changed the base branch from main to test-onrepeat-tests January 15, 2024 03:05
@trusktr trusktr merged commit af0f7a9 into tweenjs:test-onrepeat-tests Jan 15, 2024
@trusktr
Copy link
Member

trusktr commented Jan 15, 2024

merged finally!

@trusktr trusktr mentioned this pull request Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a test for onRepeat
2 participants