generated at
NativeScrollEvent
react-native/Libraries/Components/ScrollView/ScrollView.d.ts
export interface NativeScrollEvent { contentInset: NativeScrollRectangle; contentOffset: NativeScrollPoint; contentSize: NativeScrollSize; layoutMeasurement: NativeScrollSize; velocity?: NativeScrollVelocity | undefined; zoomScale: number; /** * @platform ios */ targetContentOffset?: NativeScrollPoint | undefined; }

>

イメージ
ts
const handleScroll = (e: NativeScrollEvent) => { if (isCloseToRight(e)(offset)) {...} if (isCloseToLeft(e)(offset)) {...} }; const isCloseToRight = ({ layoutMeasurement, contentOffset, contentSize }: NativeScrollEvent) => (threshold: number) => { return ( layoutMeasurement.width + contentOffset.x >= contentSize.width - threshold ); }; const isCloseToLeft = ({ contentOffset }: NativeScrollEvent) => (threshold: number) => { return contentOffset.x <= threshold; };