expo / react-native-action-sheet

A cross-platform ActionSheet for React Native
MIT License
1.37k stars 224 forks source link

Best way to get the height of the Action Sheet? #292

Closed JacobJaffe closed 1 year ago

JacobJaffe commented 1 year ago

Hello, I'm working with a scenario where I've got a lot of action sheets that have dynamically constructed options. Some of these are triggered by items inside of FlatLists.

I'd like to scroll to the item when clicking, AND include the offset of the action sheet. To do this, I'd need to know the height of the action sheet when calling scrollToIndex({ index, viewPosition: 1}). Without this, the FlatList scrolls to the item, but not relative to the action sheet.

Basically, I want to achieve the offsetting that you can get with a KeyboardAvoidingView, but with the ActionSheet. I'd like to have consistency with scrolling to viewPosition: 1, which causes the content to scroll to the end of the window

Any advice on the best way to go about determining what the height of the action sheet is would be appreciated.

Thank you!

bradbyte commented 1 year ago

Maybe you could try locally if you expose the ref to the ActionGroup component, it will give you a node you can use to measure?

https://github.com/expo/react-native-action-sheet/blob/master/src/ActionSheetProvider.tsx#L19

bradbyte commented 1 year ago

Closing for inactivity.. Please reopen if needed. Thanks!