웹 페이지 프론트엔드 UI 수정
- 모바일에서 봤을 때 UI/UX 이상하고 불편했던 부분 수정 - 블로그 글 모바일 크기 시 리스트 아래로 글이 내려가는 부분 수정 - 전체 배경 이어 붙이기가 아닌 고정으로 스크롤 시에도 어색하지 않게 수정
This commit is contained in:
@@ -169,6 +169,7 @@ const Travel = () => {
|
||||
const [regionsGeojson, setRegionsGeojson] = useState(null);
|
||||
const [selectedPhotoIndex, setSelectedPhotoIndex] = useState(null);
|
||||
const [modalOffset, setModalOffset] = useState(24);
|
||||
const [touchStartX, setTouchStartX] = useState(null);
|
||||
const cacheRef = useRef(new Map());
|
||||
const cacheTtlMs = 10 * 60 * 1000;
|
||||
|
||||
@@ -292,8 +293,42 @@ const Travel = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleTouchStart = (event) => {
|
||||
if (selectedPhotoIndex === null) return;
|
||||
const touch = event.touches[0];
|
||||
setTouchStartX(touch.clientX);
|
||||
};
|
||||
|
||||
const handleTouchEnd = (event) => {
|
||||
if (selectedPhotoIndex === null || touchStartX === null) return;
|
||||
const touch = event.changedTouches[0];
|
||||
const deltaX = touch.clientX - touchStartX;
|
||||
if (Math.abs(deltaX) > 50) { // 스와이프 거리 임계값
|
||||
if (deltaX > 0) {
|
||||
// 왼쪽으로 스와이프: 이전 사진
|
||||
setSelectedPhotoIndex((prev) =>
|
||||
prev === null
|
||||
? prev
|
||||
: (prev - 1 + photos.length) % photos.length
|
||||
);
|
||||
} else {
|
||||
// 오른쪽으로 스와이프: 다음 사진
|
||||
setSelectedPhotoIndex((prev) =>
|
||||
prev === null ? prev : (prev + 1) % photos.length
|
||||
);
|
||||
}
|
||||
}
|
||||
setTouchStartX(null);
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
return () => window.removeEventListener('keydown', handleKeyDown);
|
||||
window.addEventListener('touchstart', handleTouchStart);
|
||||
window.addEventListener('touchend', handleTouchEnd);
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
window.removeEventListener('touchstart', handleTouchStart);
|
||||
window.removeEventListener('touchend', handleTouchEnd);
|
||||
};
|
||||
}, [photos.length, selectedPhotoIndex]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user