728x90
반응형
Flatlist 나 scrollview에서 pagingEnabled 를 하면, snap 하는 느낌은 들지만, scroll의 offset 이 맞지않는 경우가 많다..
이를 위해
const offset = heightScale(600) + 2 * cardVerticalMargin;
const snapToOffsets = useMemo(
() =>
Array.from(Array(DUMMY.length)).map(
(_, index) => index * offset - headerHeight,
),
[DUMMY],
);
이런식으로 사용하면,
어느 offset들에게 걸릴지가 snapToOffesets props 에 의해 flatlist / scrollview 에 전달된다.
pagingEnabled
decelerationRate="fast"
scrollEventThrottle={16}
snapToOffsets={snapToOffsets}
주로 같이쓰는 옵션들이다.
728x90
반응형
'ReactNative' 카테고리의 다른 글
[ React Native ] ImageBackground borderRadius (0) | 2023.11.01 |
---|---|
[ React Native ] Figma font scale (0) | 2023.10.31 |
[ React Native ] Sticky Header with animated View (0) | 2023.10.31 |
[ React Native ] flatlist scrollview onScroll 시, position 이동 및 스크롤에 따른 데이터 변경시 함수 작성 (1) | 2023.10.27 |
[ React Native ] LayoutAnimation 을 사용한 ui 예제 (0) | 2023.10.26 |