Skip to content

Conversation

@eastroot1590
Copy link
Contributor

closed bottom sheet can't directly snap to 100% because initial animatedNextPosition is 0 and 100%'s nextPosition is 0 too.

Motivation

this kind of sheets can't open

const snapPoint = ['100%'];
const ref = useRef<BottomSheet>(null);

const handlePress = () => {
    // doesn't work
    ref.current?.snapToIndex(0);
};

return (
  <Container>
    <Button onPress={handlePress} />
    <BottomSheet
      ref={ref}
      index={-1}
      snapPoints={snapPoint}
    />
  </Container>
)

in animateToPositionCompleted, animatedNextPosition always set to Number.NEGATIVE_INFINITY so this value can be initial value.

closed bottom sheet can't directly snap to 100% because initial animatedNextPosition is 0 and 100%'s nextPosition is 0 too.
Copy link

@bpolonia bpolonia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm facing the same issue.

I just tested it. This fixes it.

Thanks!

@gorhom gorhom self-assigned this Jul 29, 2022
@gorhom gorhom added the v4 Written in Reanimated v2 label Jul 29, 2022
@gorhom gorhom closed this Jul 31, 2022
gorhom added a commit that referenced this pull request Jul 31, 2022
* fix: closed bottom sheet snap point

closed bottom sheet can't directly snap to 100% because initial animatedNextPosition is 0 and 100%'s nextPosition is 0 too.

* refactor: extracted initial next value to constants file

Co-authored-by: Bran <[email protected]>
@gorhom
Copy link
Owner

gorhom commented Jul 31, 2022

thanks @eastroot1590 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 Written in Reanimated v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants