Skip to content

Instantly share code, notes, and snippets.

@douglas-henrique
Last active March 28, 2023 12:35
Show Gist options
  • Save douglas-henrique/df836066f2671d8995ed173eaa573ca8 to your computer and use it in GitHub Desktop.
Save douglas-henrique/df836066f2671d8995ed173eaa573ca8 to your computer and use it in GitHub Desktop.
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