Skip to content

Commit 417cb05

Browse files
committed
perf: Add more information to annotation mode change events
Specifically, this add "oldCoordinates" to the event. If there was an active annotation before the mode change, these are the annotation's coordinates before the change. This will be an empty list if an annotation in create state had not been started and a non-empty list if it is partially created.
1 parent 8d5c9f1 commit 417cb05

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/annotationLayer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,10 @@ var annotationLayer = function (arg) {
707707
} else {
708708
m_keyHandler.unbind('esc');
709709
}
710-
let oldState;
710+
let oldState, oldCoordinates;
711711
if (m_this.currentAnnotation) {
712712
oldState = m_this.currentAnnotation.state();
713+
oldCoordinates = m_this.currentAnnotation._copyOfCoordinates();
713714
switch (m_this.currentAnnotation.state()) {
714715
case geo_annotation.state.create:
715716
m_this.removeAnnotation(m_this.currentAnnotation);
@@ -757,8 +758,9 @@ var annotationLayer = function (arg) {
757758
m_this.map().interactor().addAction(action);
758759
});
759760
}
761+
console.log({mode: m_mode, oldMode, oldState, oldCoordinates, reason});
760762
m_this.geoTrigger(geo_event.annotation.mode, {
761-
mode: m_mode, oldMode: oldMode, oldState: oldState, reason: reason});
763+
mode: m_mode, oldMode, oldState, oldCoordinates, reason});
762764
if (oldMode === m_this.modes.edit || oldMode === m_this.modes.cursor) {
763765
m_this.modified();
764766
}

src/event.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,10 @@ geo_event.annotation.state = 'geo_annotation_state';
753753
* @property {string?} oldState If there was an active annotation before the
754754
* mode change, this is the annotation state before the change. This is
755755
* one of the values from {@link geo.annotation.state}.
756+
* @property {string?} oldCoordinates If there was an active annotation before
757+
* the mode change, these are the annotation's coordinates before the
758+
* change. This will be an empty list if an annotation in create state
759+
* had not been started and a non-empty list if it is partially created.
756760
* @property {string?} reason An optional string that was passed to the mode
757761
* change method.
758762
*/

0 commit comments

Comments
 (0)