Skip to content

Commit

Permalink
Added Mouse Event on Point Hover or Point Click
Browse files Browse the repository at this point in the history
  • Loading branch information
OssamaRafique committed Aug 29, 2023
1 parent a15776f commit 7dda439
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/epiviz.gl/data-processor-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ self.onmessage = (message) => {
const result = self.processor.getClosestPoint(message.data.point);
postMessage({
type: message.data.type,
event: message.data?.event,
...result,
});
break;
Expand Down
6 changes: 4 additions & 2 deletions src/epiviz.gl/mouse-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ class MouseReader {
"mousemove",
(event) => {
this.handler.getClosestPoint(
this._calculateViewportSpot(...getLayerXandYFromEvent(event))
this._calculateViewportSpot(...getLayerXandYFromEvent(event)),
cloneMouseEvent(event)
);
if (!mouseDown) {
return;
Expand Down Expand Up @@ -262,7 +263,8 @@ class MouseReader {
"dblclick",
(event) => {
this.handler.getClickPoint(
this._calculateViewportSpot(...getLayerXandYFromEvent(event))
this._calculateViewportSpot(...getLayerXandYFromEvent(event)),
cloneMouseEvent(event)
);
},
false
Expand Down
8 changes: 6 additions & 2 deletions src/epiviz.gl/webgl-vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,13 @@ class WebGLVis {
* Does not return, posts result to this.dataWorkerStream.
*
* @param {Array} point to get closest point to
* @param {Object=} event refers to mouse eventt hat triggered this function. Optional Parameter
*/
getClosestPoint(point) {
getClosestPoint(point, event) {
this.dataWorker.postMessage({
type: "getClosestPoint",
point,
event,
});
}

Expand All @@ -257,11 +259,13 @@ class WebGLVis {
* Does not return, posts result to this.dataWorkerStream.
*
* @param {Array} point to get closest point to
* @param {Object=} event refers to mouse event that triggered this function. Optional parameter
*/
getClickPoint(point) {
getClickPoint(point, event) {
this.dataWorker.postMessage({
type: "getClickPoint",
point,
event,
});
}

Expand Down

0 comments on commit 7dda439

Please sign in to comment.