Skip to content

Commit

Permalink
feat(🖱): useScrollHander() and scrollHandler() (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Jul 1, 2020
1 parent 699c957 commit b2bcbf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/Gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,18 @@ export const rotationGestureHandler = () => {
};
};

export const scrollHandler = () => {
const x = new Value(0);
const y = new Value(0);
const onScroll = onScrollEvent({ x, y });
return {
x,
y,
onScroll,
scrollEventThrottle: 1,
};
};

export const debugGestureState = (
label: string,
state: Animated.Node<State>
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/Hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
pinchGestureHandler,
rotationGestureHandler,
tapGestureHandler,
scrollHandler,
} from "./Gesture";
import { Vector, vec } from "./Vectors";
import { loop } from "./AnimationRunners";
Expand All @@ -30,6 +31,7 @@ export const useRotationGestureHandler = () =>
export const usePinchGestureHandler = () =>
useLazyRef(() => pinchGestureHandler());
export const useTapGestureHandler = () => useLazyRef(() => tapGestureHandler());
export const useScrollHandler = () => useLazyRef(() => scrollHandler());

type Atomic = string | number | boolean;

Expand Down

0 comments on commit b2bcbf5

Please sign in to comment.