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

feat: added dynamic snap point based on content height (#32) #57

Closed
wants to merge 8 commits into from

Conversation

gorhom
Copy link
Owner

@gorhom gorhom commented Nov 4, 2020

closes (#32)

Install

yarn add ssh://git@github.com:gorhom/react-native-bottom-sheet#feature/dynamic-snap-point

Todo

  • Allow to provide 1 point when shouldMeasureContentHeight is true.
  • Add transition to sheet when content height change.
  • Add documentation for shouldMeasureContentHeight.

@gorhom gorhom linked an issue Nov 4, 2020 that may be closed by this pull request
@EricPKerr
Copy link

EricPKerr commented Nov 8, 2020

It would be nice if this supported going from snapPoints = [0, 200]; (with current index/value being 200), and then switch to snapPoints = [0, 100, 200]; and it keeps the same current position value, but just internally updates the index.

Similarly, if it goes from [0, 200, 400] and the current is 400, and then goes to different values like [0, 500] it finds the closest new snapPoint and transitions to that.

@likern
Copy link
Contributor

likern commented Nov 19, 2020

I looked at your PR. It uses Reanimated V1. Should dynamic snap later be ported to Reanimated V2 in this branch https://github.com/gorhom/react-native-bottom-sheet/tree/feature/rewrite-in-reanimated-v2?

Could you clarify library roadmap?

@gorhom
Copy link
Owner Author

gorhom commented Nov 19, 2020

hi @likern , thanks for pointing this out. it become clearly that i need to set a roadmap for v2 that also includes the reanimated v2 version.

I look into planning it later and will put on the project board 👍

@likern
Copy link
Contributor

likern commented Nov 19, 2020

It would be nice if this supported going from snapPoints = [0, 200]; (with current index/value being 200), and then switch to snapPoints = [0, 100, 200]; and it keeps the same current position value, but just internally updates the index.

Similarly, if it goes from [0, 200, 400] and the current is 400, and then goes to different values like [0, 500] it finds the closest new snapPoint and transitions to that.

I think instead of fixed snapPoints and all complexity related to dynamic things it's better to allow user to provide worklet function which will calculate snapPoint dynamically. So there would be no limitation to how much of them and how to convert between different snapPoint sets.

I did similar in my https://github.com/likern/react-native-enhanced-popup-menu, where the final position on popup is determined at runtime, at moment when user clicked to show popup menu.

User could provide computeOffset(left, top, width, height) where in callback he gets coordinated of base component. And he can do any dynamic calculations to do anything with final position.

It think we could do the same. And final snapPoint will be determined dynamically at time when bottomsheet is released.

@gorhom gorhom closed this Nov 21, 2020
@gorhom gorhom deleted the feature/dynamic-snap-point branch November 27, 2020 14:52
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.

Dynamic Bottom Sheet height based on Children height
3 participants