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

fix: Default animatedNextPositionIndex to INITIAL_VALUE #1960

Merged

Conversation

dfalling
Copy link
Contributor

@dfalling dfalling commented Oct 8, 2024

Motivation

This fix is very similar to #1035 and #1043

BottomSheet will sometimes not animate/expand because of this logic. This can happen when you have a single snapPoint, or if you use enableDynamicSizing.

Issue

animatedNextPositionIndex starts at 0, which is the same as snapPoints.length -1, causing the animation to be aborted.

Starting values:

const animatedNextPosition = useSharedValue(INITIAL_VALUE);
const animatedNextPositionIndex = useSharedValue(0);

After a successful animation, it is reset correctly to the right value:

Reset values:

animatedNextPosition.value = INITIAL_VALUE;
animatedNextPositionIndex.value = INITIAL_VALUE;

It should always start at INITIAL_VALUE (-Infinity) like animatedNextPosition.

Reproducing

Note: this isn't always reproducible for me. I have two identical BottomSheets, and only one of them is broken. Something in the working one is resetting the animatedNextPositionIndex.value to -Infinity before the animation runs, but I'm struggling to debug where that's happening.

@gorhom gorhom added the v5 label Oct 8, 2024
@gorhom gorhom self-assigned this Oct 8, 2024
@gorhom gorhom force-pushed the master branch 13 times, most recently from 76801d5 to c941c83 Compare October 13, 2024 15:51
@gorhom
Copy link
Owner

gorhom commented Oct 14, 2024

thanks @dfalling for submitting this PR

@gorhom gorhom merged commit 1cf3e41 into gorhom:master Oct 14, 2024
@dfalling dfalling deleted the df/fix_animatedNextPositionIndex_initial_value branch October 22, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants