풋터
This commit is contained in:
@@ -96,19 +96,33 @@ export const FooterNavigation = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
let previousTouch: any;
|
||||
|
||||
const handleScroll = () => {
|
||||
if(window.scrollY > window.outerHeight / 3){
|
||||
setIsFooterOn(true);
|
||||
}
|
||||
else{
|
||||
setIsFooterOn(false);
|
||||
}
|
||||
const handleTouchStart = (e: TouchEvent) => {
|
||||
const touch: Touch | undefined = e.touches[0];
|
||||
previousTouch = touch;
|
||||
};
|
||||
const handleTouchMove = (e: TouchEvent) => {
|
||||
const touch: Touch | undefined = e.touches[0];
|
||||
let movementY: number | undefined;
|
||||
if(touch && previousTouch){
|
||||
movementY = touch.pageY - previousTouch.pageY;
|
||||
if(movementY > 0){
|
||||
setIsFooterOn(false);
|
||||
}
|
||||
else{
|
||||
setIsFooterOn(true);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
|
||||
window.addEventListener('touchstart', handleTouchStart);
|
||||
window.addEventListener('touchmove', handleTouchMove);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('scroll', handleScroll);
|
||||
window.removeEventListener('touchstart', handleTouchStart);
|
||||
window.removeEventListener('touchmove', handleTouchMove);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user