Last active
March 28, 2023 12:35
-
-
Save douglas-henrique/df836066f2671d8995ed173eaa573ca8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { useState } from 'react' | |
type ScrollProps = { | |
layoutMeasurement: { | |
height: number | |
} | |
contentOffset: { | |
y: number | |
} | |
contentSize: { | |
height: number | |
} | |
} | |
export default function Component(){ | |
const scroll = ({ | |
contentSize, | |
contentOffset, | |
layoutMeasurement | |
}: ScrollProps) => { | |
return ((layoutMeasurement.height + contentOffset.y) / contentSize.height) * 100 //return scroll in % | |
} | |
return ( | |
<ScrollView onScroll={(event) => scroll(event.nativeEvent)} scrollEventThrottle={16}> </ScrollView> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment