@@ -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
0 commit comments