<aside> 💡 2022.12.05. 김관경
</aside>
const moveSectionScroll = useCallback(
throttle((e: WheelEvent) => {
e.preventDefault();
// 아래 스크롤
if (e.deltaY > 0 && pageRef.current < maxPage) {
pageRef.current += 1;
}
if (e.deltaY < 0 && pageRef.current > 0) {
pageRef.current -= 1;
}
window.scrollTo(0, pageRef.current * window.innerHeight);
}, 500),
[maxPage],
);
useMemo(() => foo, [foo]);
useCallback((bar) => foo(bar), [foo]);
const moveSectionScroll = useCallback(
(callback: CallbackFunc<any[]>, waitingTime: number) => (...args: any[]) => {
if (isWaiting) {
callback(...args);
isWaiting = false;
setTimeout(() => {
isWaiting = true;
}, waitingTime);
}
}
);
const moveSectionScroll = useMemo(
() => throttle((e: WheelEvent) => {
e.preventDefault();
// 아래 스크롤
if (e.deltaY > 0 && pageRef.current < maxPage) {
pageRef.current += 1;
}
if (e.deltaY < 0 && pageRef.current > 0) {
pageRef.current -= 1;
}
window.scrollTo(0, pageRef.current * window.innerHeight);
}, 500),
[maxPage],
);