From bdf137f5b74795d4bae3bfd4116f675e37361c09 Mon Sep 17 00:00:00 2001 From: ponlawat-w Date: Tue, 28 Nov 2023 17:04:17 +0700 Subject: [PATCH] Added events dispatching --- README.md | 17 ++++++--- examples/index.html | 23 ++++++++++-- package.json | 2 +- src/event.ts | 55 ++++++++++++++++++++++++++++ src/index.ts | 1 + src/interaction.ts | 62 +++++++++++++++++++++++++++++--- tests/common.ts | 14 ++++---- tests/interaction.create.test.ts | 47 +++++++++++++++++++++++- tests/interaction.edit.test.ts | 48 ++++++++++++++++++++++++- webpack.config.js | 1 + 10 files changed, 247 insertions(+), 23 deletions(-) create mode 100644 src/event.ts diff --git a/README.md b/README.md index 1615534..c4f4bc4 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,20 @@ map.addInteraction(interaction); If `waySource` is not provided, `OSMOverpass` will be used as source for snapping, so the constructor options for `OSMWaySnap` will be extended to include [thoses options from `OSMOverpassSourceBase`](https://github.com/ponlawat-w/ol-osmoverpass#constructor-options). +## Events + +All event objects dispatched have property `feature` being the active feature of the interaction. + +Event types: +- `waysnapstart`: when the interaction starts on a feature whether creation or edition. +- `waysnapstartcreate`: when the interaction has created a new feature. +- `waysnapstartedit`: when the interaction has started edition an existing feature. +- `waysnapupdate`: when the interaction has updated the active feature. +- `waysnapend`: when interaction has finished. + ## Examples -[Full page example using the library from CDN](./examples/index.html) +[Examples in HTML using CDN](./examples/index.html) ### Using as module @@ -110,8 +121,4 @@ const interaction = new OSMWaySnap({ map.addInteraction(interaction); ``` -### Using as CDN - -[HTML Example](./examples/index.html) - --- diff --git a/examples/index.html b/examples/index.html index d9d4f2e..08da00e 100644 --- a/examples/index.html +++ b/examples/index.html @@ -37,9 +37,11 @@ +
+ + | +
- -