@dnanpm/styleguide
Version:
DNA Styleguide repository provides the set of components and theme object used in various DNA projects.
25 lines (24 loc) • 768 B
TypeScript
import type { MutableRefObject } from 'react';
/**
* Hook to follow scroll position without rerendering the view.
* Modified to ES6 and work with SSR (fixed window undefined error) and Rocket architecture from https://www.npmjs.com/package/@n8tb1t/use-scroll-position
*/
interface ScrollPosition {
x: number;
y: number;
}
interface ScrollPositionProps {
prevPos: ScrollPosition;
currPos: ScrollPosition;
}
declare const useScrollPosition: {
(effect: {
({ prevPos, currPos }: ScrollPositionProps): void;
}, element: MutableRefObject<Element> | undefined, useWindow: boolean, wait: number): void;
defaultProps: {
element: boolean;
useWindow: boolean;
wait: null;
};
};
export default useScrollPosition;