terra-draw icon indicating copy to clipboard operation
terra-draw copied to clipboard

[Bug] Actual pointerDistance is smaller than what the cursor suggests when editing vertexes

Open SirPryderi opened this issue 2 months ago • 1 comments
trafficstars

Describe the bug In select mode (and possibly other modes too) the radius suggested by the cursor changing when nearing a midpoint or vertex does not reflect what it actually is for the on click behaviour. In fact, it seems to be ~2 times as much.

Terra Draw npm version 1.15.0

To Reproduce Steps to reproduce the behavior:

  1. Go to the 'Select with Mid Points' story on storybook
  2. Create a polygon
  3. Switch to select mode
  4. Starting far from the polygon slowly approach a midpoint until the cursor switches to a crosshair and stop
  5. Click with the left mouse button
  6. Observe how the polygon was deselected instead of a new midpoint being created

Expected behavior It is expected that the activation area hinted by the cursor changing reflects the actual onClick behaviour.

Screenshots Notice here how it deselects after I click as soon as the cursor turns to a crosshair, instead of creating a midpoint. Unfortunately the video does not show when the click happen but it should be easy to tell because the feature gets deselected, until the last click that is within the actual range and a midpoint is created instead.

https://github.com/user-attachments/assets/5d21e774-c7db-42ae-a55c-d631da423617

Desktop (please complete the following information):

  • OS: macOS 15.6.1
  • Browser: chrome
  • Version 140.0.7339.133

Additional context I have investigated the cause, and I believe it has something to do with how here the midpoint/vertex distance threshold is calculated as the radius around the point, whereas onLeft click the features are retrieved (here) using the a bounding box around the cursor location.

I have tested in a fork that by changing the onMouseMove distance threshold to half of the pointerDistance it's closer to the actual threshold, but still not 100% accurate.

I'm more than happy to open a PR to address the issue if some guidance is provided. I would imagine that using the FeatureAtPointerEventBehavior during the onMouseMove event to find the midpoints would address the inconsistencies, but I am concerned about the performance implications of doing that.

SirPryderi avatar Sep 25 '25 14:09 SirPryderi