import { useEffect } from 'react';
import useStickyState from './useStickyState';
// NOTE: Images without height will make scroll position to be set incorrectly
// NOTE: Set image height to get correct scroll position
// Get scroll position (horizontal scroll currently)
export default function useScrollPosition(elementRef) {
const [scroll, setScroll] = useStickyState('comedians-page-ss', null);
const onScroll = () => {
setScroll({ top: window.scrollY });
};
useEffect(() => {
window.addEventListener('scroll', onScroll);
return () => {
window.removeEventListener('scroll', onScroll);
};
}, []);
}