Hi,
When I set
initialSnap={1}
with
const snapPoints = [sheetHeight, 0];
where sheetHeight comes from the props, the BottomSheet is already open. There is nothing I can do to change it, it seems so.
Same here
Had the same issue, which was related to the fact, that my sheetHeight was initially 0.
Seems like found a workaround for this.
1) You can still initialize sheetHeight with initial value 0.
2) Then make sure you do not render BottomSheet when sheetHeight == 0:
{sheetHeight > 0 && (
<BottomSheet snapPoints={[sheetHeight, ...]} ... />
)}
The general problem is that, when the sheet height dynamically changes, the positioning of the sheet (at snapPoint 0) is not adjusted -- which makes the sheet seem to jump to a snap point value of
(heightAfterDynamicChange - heightBeforeDynamicChange).
@kyryloz's solution works only if the sheet does not have to be rendered at the lower height, but not if both heights represent actual content. I had this problem for a menu which could contain a different number of items, depending on the app state.
The only solution to the problem seems to be to make sure that the highest snap point stays constant. I.e., I would have three snap points, [maxHeight, dynamicHeight, 0], and if the menu opens, I snap to dynamicHeight (so the maxHeight snap point is not actually used). For the case that the user does drag the bottom sheet further up to the maxHeight snap point, I render white space of height (maxHeight - dynamicHeight) below the actual sheet content.
There was a reported issue about unwanted behaviour when snapPoints are not in descending order inside the array (note has already been added to README). If the whole problem is connected to the initial value as @kyryloz stated, @mitschabaude's solution should work, but it's also worth to mention that if there's more than one dynamic snapPoint you should remember to keep them ordered. I think that should be enough.
@mitschabaude Could you show me an example?