JamesLMilner / terra-draw

A library for drawing on maps that supports Mapbox, MapLibre, Google Maps, OpenLayers and Leaflet out the box
https://terradraw.io
MIT License
447 stars 50 forks source link

feat: context object for onFinish to allow more control for developers #261

Closed JamesLMilner closed 3 months ago

JamesLMilner commented 3 months ago

Description of Changes

Adds context object to onFinish event to provide more context to how the finish event happened. This means you should be able to do this going forward:

draw.on("finish", (id: string, context: { action: string, mode: string }) => {
  if (action === 'draw') {
    // Do something for draw finish event
  } else if (action === 'dragFeature') {
    // Do something for a drag finish event
  } else if (action === 'dragCoordinate') {
    //
  }else if (action === 'dragCoordinateResize') {
    //
  }
});

Link to Issue

253

PR Checklist