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

Feedback for “Parallax” #749

Open
nzcodarnoc opened this issue Dec 24, 2024 · 2 comments
Open

Feedback for “Parallax” #749

nzcodarnoc opened this issue Dec 24, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@nzcodarnoc
Copy link

The documentation seems to be out of step with the api, suggesting that onProgressChange={progress} will work when progress is defined as const progress = useSharedValue<number>(0);

When I implemented this my IDE complained about a typescript error and the app crashed with an error from reanimated.

What I am observing is that onProgressChange needs a callback with the following function signature.

  const offsetProgress = useSharedValue<number>(0);
  const absoluteProgress = useSharedValue<number>(0);
  const handleProgressChange = (newOffsetProgress: number, newAbsoluteProgress: number) => {
    offsetProgress.value = newOffsetProgress;
    absoluteProgress.value = newAbsoluteProgress;
  }

So that the prop in question is now onProgressChange={handleProgressChange}

For react-native-reanimated-carousel 3.5.1

Copy link

dosubot bot commented Dec 24, 2024

Hey @nzcodarnoc! I'm here to help you with any software bugs, questions, or contributions. Let's tackle this together!

The feedback is correct. The documentation for "Parallax" in "react-native-reanimated-carousel 3.5.1" incorrectly suggests using onProgressChange={progress}. The onProgressChange prop requires a callback function, not a shared value. The correct usage involves passing a function like handleProgressChange with the signature:

(value: number, absoluteProgress: number) => void

This function updates the shared values for progress, as you've described [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the documentation Improvements or additions to documentation label Dec 24, 2024
@nzcodarnoc
Copy link
Author

nzcodarnoc commented Dec 24, 2024

Thanks bot @dosu, since we are chatting, do you know how to set the centre "focus" item in a long horizontal parallax carousel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant