Skip to content

Commit 03b11c1

Browse files
committed
chore: refine previous fix
1 parent 13afd08 commit 03b11c1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/hooks/useStopFollowingOnFly.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ export function useStopFollowingOnFly(map, lc) {
1111
useEffect(() => {
1212
if (!map || !lc) return undefined
1313

14-
const originalFlyTo = map.flyTo
15-
16-
map.flyTo = (...args) => {
17-
if (lc._active && lc._event && lc.stopFollowing) {
14+
const handleMove = (event) => {
15+
if (event?.flyTo && lc._active && lc._event && lc.stopFollowing) {
1816
lc.stopFollowing()
1917
}
20-
return originalFlyTo.apply(map, args)
2118
}
2219

20+
map.on('move', handleMove)
21+
2322
return () => {
24-
map.flyTo = originalFlyTo
23+
map.off('move', handleMove)
2524
}
2625
}, [map, lc])
2726
}

0 commit comments

Comments
 (0)