Skip to content

Commit 09c83dc

Browse files
authored
Merge pull request #4 from Alfex4936/feature/refactor-fix
fix: pulse circle positioning and roadview context menu on map movement
2 parents 4c2b371 + 1e60ad8 commit 09c83dc

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

components/layout/kakao-map.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const KakaoMap = ({ deviceType = "desktop" }: { deviceType?: Device }) => {
5353

5454
const mapRef = useRef<Nullable<HTMLDivElement>>(null);
5555
const longPressTimer = useRef<NodeJS.Timeout | null>(null);
56+
const touchStartPos = useRef<{ x: number; y: number } | null>(null);
5657

5758
useEffect(() => {
5859
const fetch = async () => {
@@ -114,6 +115,12 @@ const KakaoMap = ({ deviceType = "desktop" }: { deviceType?: Device }) => {
114115
const handleTouchStart = (e: TouchEvent) => {
115116
const touch = e.touches[0];
116117

118+
// Store initial touch position
119+
touchStartPos.current = {
120+
x: touch.clientX,
121+
y: touch.clientY,
122+
};
123+
117124
longPressTimer.current = setTimeout(() => {
118125
// Convert screen coordinates to map coordinates
119126
const x = touch.clientX;
@@ -143,12 +150,23 @@ const KakaoMap = ({ deviceType = "desktop" }: { deviceType?: Device }) => {
143150
clearTimeout(longPressTimer.current);
144151
longPressTimer.current = null;
145152
}
153+
touchStartPos.current = null;
146154
};
147155

148-
const handleTouchMove = () => {
149-
if (longPressTimer.current) {
150-
clearTimeout(longPressTimer.current);
151-
longPressTimer.current = null;
156+
const handleTouchMove = (e: TouchEvent) => {
157+
if (longPressTimer.current && touchStartPos.current) {
158+
const touch = e.touches[0];
159+
const moveDistance = Math.sqrt(
160+
Math.pow(touch.clientX - touchStartPos.current.x, 2) +
161+
Math.pow(touch.clientY - touchStartPos.current.y, 2)
162+
);
163+
164+
// Cancel long-press if moved more than 10 pixels (indicates drag/pan intent)
165+
if (moveDistance > 10) {
166+
clearTimeout(longPressTimer.current);
167+
longPressTimer.current = null;
168+
touchStartPos.current = null;
169+
}
152170
}
153171
};
154172

lib/create-user-location-marker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ const createUserLocationMarker = (
116116
style.textContent = `
117117
@keyframes pulse {
118118
0% {
119-
transform: scale(1);
119+
transform: translate(-50%, -50%) scale(1);
120120
opacity: 0.6;
121121
}
122122
100% {
123-
transform: scale(2);
123+
transform: translate(-50%, -50%) scale(2);
124124
opacity: 0;
125125
}
126126
}

0 commit comments

Comments
 (0)