Skip to content

Commit

Permalink
refactor: rename methods in AutoScrollScrollView
Browse files Browse the repository at this point in the history
  • Loading branch information
le-ar committed Jan 29, 2024
1 parent 7ddb301 commit 72cdff1
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/components/AutoScrollScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,21 @@ export function AutoScrollScrollView(
scrollAnimInfo.value = null;
}, [scrollAnimInfo]);

const scrollToLocal = useCallback(
const scrollToInstantly = useCallback(
(offset: Offset) => {
'worklet';
scrollTo(scrollRef, offset.x, offset.y, false);
},
[scrollRef]
);
const scrollToAnim = useCallback(
(x: number, y: number) => {
'worklet';

scrollTo(scrollRef, x, y, true);
},
[scrollRef]
);

const isScrollAnimActive = useDerivedValue(() => {
return scrollAnimInfo.value != null;
Expand Down Expand Up @@ -171,7 +179,7 @@ export function AutoScrollScrollView(
isScrollAnimActive,
scrollOffset,
scrollSpeed,
scrollToLocal,
scrollToInstantly,
startScroll,
stopScroll,
needScroll,
Expand Down Expand Up @@ -203,15 +211,6 @@ export function AutoScrollScrollView(
}
}, [id, handlerId, horizontal, horizontalProps]);

const scrollToLocalJs = useCallback(
(x: number, y: number) => {
'worklet';

scrollTo(scrollRef, x, y, true);
},
[scrollRef]
);

const measureLocal = useCallback(() => {
'worklet';

Expand Down Expand Up @@ -239,7 +238,7 @@ export function AutoScrollScrollView(
stopScroll: stopScrollRoot,
registerScroll: registerScrollRoot,
removeScroll: removeScrollRoot,
scrollTo: scrollToLocalJs,
scrollTo: scrollToAnim,
measure: measureLocal,
getRelativeCoords: getRelativeCoordsLocal,
}),
Expand All @@ -249,7 +248,7 @@ export function AutoScrollScrollView(
stopScrollRoot,
registerScrollRoot,
removeScrollRoot,
scrollToLocalJs,
scrollToAnim,
measureLocal,
getRelativeCoordsLocal,
]
Expand Down

0 comments on commit 72cdff1

Please sign in to comment.