-
-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: addressed an edge case with scrollview content sizing on initial…
… rendering on safari
- Loading branch information
Showing
3 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
59 changes: 57 additions & 2 deletions
59
src/components/bottomSheetScrollable/ScrollableContainer.web.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/components/bottomSheetScrollable/useBottomSheetContentSizeSetter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useCallback } from 'react'; | ||
import { useBottomSheetInternal } from '../../hooks'; | ||
|
||
/** | ||
* A hook to set the content size properly into the bottom sheet, | ||
* internals. | ||
* | ||
* @param enableFooterMarginAdjustment Adjust the scrollable bottom margin to avoid the animated footer. | ||
* @returns | ||
*/ | ||
export function useBottomSheetContentSizeSetter( | ||
enableFooterMarginAdjustment: boolean | ||
) { | ||
//#region hooks | ||
const { enableDynamicSizing, animatedContentHeight, animatedFooterHeight } = | ||
useBottomSheetInternal(); | ||
//#endregion | ||
|
||
//#region methods | ||
const setContentSize = useCallback( | ||
(contentHeight: number) => { | ||
if (enableDynamicSizing) { | ||
animatedContentHeight.value = | ||
contentHeight + | ||
(enableFooterMarginAdjustment ? animatedFooterHeight.value : 0); | ||
} | ||
}, | ||
[ | ||
enableDynamicSizing, | ||
animatedContentHeight, | ||
animatedFooterHeight, | ||
enableFooterMarginAdjustment, | ||
] | ||
); | ||
//#endregion | ||
|
||
return { | ||
setContentSize, | ||
}; | ||
} |