Skip to content

Commit

Permalink
Merge pull request #462 from xBimTeam/fix/canvas-mouse-move
Browse files Browse the repository at this point in the history
Fixed hovering elements when the mouse over event is not from the viewer canvas
  • Loading branch information
Ibrahim5aad authored Aug 25, 2024
2 parents 88ad67f + 4fa2417 commit 8920fde
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/navigation/mouse-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export class MouseNavigation {
};

var handleMouseMove = (event: MouseEvent) => {
if (viewer.hoverPickEnabled && !mouseDown && viewer.navigationMode !== 'walk') {

const isCanvasOurTarget = event.target instanceof HTMLCanvasElement;

if (viewer.hoverPickEnabled && !mouseDown && viewer.navigationMode !== 'walk' && isCanvasOurTarget) {

//get coordinates within canvas (with the right orientation)
let r = viewer.canvas.getBoundingClientRect();
Expand All @@ -139,6 +142,12 @@ export class MouseNavigation {
viewer.setHoverPick(data.id, data.model);
viewer.fire('hoverpick', { id: data.id, model: data.model, event: event, xyz: data.xyz });
}

if(!isCanvasOurTarget)
{
viewer.setHoverPick(undefined, undefined);
}

if (!mouseDown) {
return;
}
Expand Down

0 comments on commit 8920fde

Please sign in to comment.