Skip to content

Instantly share code, notes, and snippets.

@reime005
Created August 9, 2020 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reime005/1a70ad5e7362e2420372cfd88030e497 to your computer and use it in GitHub Desktop.
Save reime005/1a70ad5e7362e2420372cfd88030e497 to your computer and use it in GitHub Desktop.
const scrollElementHeightPercent = 45;
export default Example = () => {
...
const [scrollViewHeight, setScrollViewHeight] = React.useState(0);
const scrollPerc = (contentOffset.y / (contentSize - scrollViewHeight))
* (100 - scrollElementHeightPercent);
return(
<ScrollView
...
onLayout={e => {
setScrollViewHeight(e.nativeEvent.layout.height);
}}
>...
</ScrollView>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment