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

withRepeat not working with withDecay #6757

Open
InkaAlicja opened this issue Nov 25, 2024 · 1 comment · May be fixed by #6772
Open

withRepeat not working with withDecay #6757

InkaAlicja opened this issue Nov 25, 2024 · 1 comment · May be fixed by #6772
Labels
Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@InkaAlicja
Copy link

Description

Using withRepeat with withDecay doesn't work. I use withDecay to create a bouncing ball effect. But wrapping it with withRepeat doesn't make the animation repeat

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-11-25.at.12.07.07.mp4

With repeat expects an animation object (docs), and withDecay returns an animation object (docs), so I think this should work.

I should mention that if I run the animation before the previous one ends, the repeat does seem to kind of work

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-11-25.at.12.11.36.mp4

Steps to reproduce

  1. Setup a new reanimated app
  2. Animate a position of a view with withDecay wrapped with withRepeat:
  const tap = Gesture.Tap()
    .maxDuration(100000)
    .onEnd(() => {
      position.value = withRepeat(withDecay({
        velocity: -1000,
        deceleration: 0.998,
        clamp: [-1, 1],
        velocityFactor: 1,
        rubberBandEffect: true,
        rubberBandFactor: 0.6,
      }),5)
    });
  1. Run iOS simulator and tap the circle

(please see the provided snack)

Snack or a link to a repository

https://snack.expo.dev/s_qw5YUp3xjzXDdDXKX5A

Reanimated version

3.16.1

React Native version

0.76.2

Platforms

iOS

JavaScript runtime

None

Workflow

None

Architecture

Fabric (New Architecture)

Build type

None

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided Platform: iOS This issue is specific to iOS labels Nov 25, 2024
@patrycjakalinska
Copy link
Contributor

patrycjakalinska commented Nov 28, 2024

Hi @InkaAlicja,

It turned out velocity from withDecay wasn't resetting after each rep. I prepared a PR that should resolve this issue.

Screen.Recording.2024-11-28.at.14.18.54.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants