[openstreetmap/openstreetmap-website] Add `autoPan`-ing for draggin markers on the diary adding page (PR #7188)
Frank Elsinga
notifications at github.com
Sun Jul 5 15:33:52 UTC 2026
@CommanderStorm commented on this pull request.
> +
+ const point = map.project(this.getLngLat()),
+ { clientWidth, clientHeight } = map.getContainer();
+
+ let dx = 0,
+ dy = 0;
+ if (point.x < edgeDistance) dx = point.x - edgeDistance;
+ else if (point.x > clientWidth - edgeDistance) dx = point.x - (clientWidth - edgeDistance);
+ if (point.y < edgeDistance) dy = point.y - edgeDistance;
+ else if (point.y > clientHeight - edgeDistance) dy = point.y - (clientHeight - edgeDistance);
+ if (!dx && !dy) return;
+
+ const clamp = (v) => Math.max(-maxPanStep, Math.min(maxPanStep, v));
+ map.panBy([clamp(dx), clamp(dy)], { duration: 0 });
+ this.setLngLat(map.unproject(point));
+ this.fire("drag");
Yes, but more because future than current.
The route page (directions/endpoint) listens to "drag" to live-update the route/endpoint while dragging, so I need to fire this event here after I have updated the location of the marker
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7188#discussion_r3525151045
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/7188/review/4631548502 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260705/6d2a8157/attachment.htm>
More information about the rails-dev
mailing list