Skip to content

Commit

Permalink
feat: add pointer move event (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrokohler authored Jun 26, 2024
1 parent 5491860 commit 1b39195
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const EVENTS = {
ROI_SELECTED: `${PROJECT_NAME}_roi_selected`,
/** Triggered when a ROI was double clicked. */
ROI_DOUBLE_CLICKED: `${PROJECT_NAME}_roi_double_clicked`,
/** Triggered when mouse moves. */
POINTER_MOVE: `${PROJECT_NAME}_pointer_move`,
/** Triggered when a ROI was modified. */
ROI_MODIFIED: `${PROJECT_NAME}_roi_modified`,
/** Triggered when a viewport move has started. */
Expand Down
26 changes: 26 additions & 0 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,32 @@ class VolumeImageViewer {
})

let clickEvent = null

this[_map].on("pointermove", (event) => {
let featureCounter = 0;
this[_map].forEachFeatureAtPixel(event.pixel, (feature) => {
const correctFeature = feature.values_?.features?.[0] || feature;
console.debug("pointermove feature id:", correctFeature);
if (correctFeature?.getId()) {
featureCounter++;
publish(this[_map].getTargetElement(), EVENT.POINTER_MOVE, {
feature: this._getROIFromFeature(
correctFeature,
this[_pyramid].metadata,
this[_affine]
),
event,
});
}
});
if (!featureCounter) {
publish(this[_map].getTargetElement(), EVENT.POINTER_MOVE, {
feature: null,
event,
});
}
});

this[_map].on('dblclick', (event) => {
if (this[_interactions].draw !== undefined) {
return
Expand Down

0 comments on commit 1b39195

Please sign in to comment.