flekschas / regl-scatterplot

Scalable WebGL-based scatter plot library build with Regl
https://flekschas.github.io/regl-scatterplot/
MIT License
185 stars 21 forks source link

fix: correctly check if mouse is over the canvas element #114

Closed flekschas closed 1 year ago

flekschas commented 1 year ago

This PR attempts to fix the point hovering issue described in #112.

Description

What was changed in this pull request?

Previously we initialized isMouseInCanvas as false. The isMouseInCanvas is making sure that we don't do unnecessary computations if the user mouses around outside the scatterplot. However, in the edge case where the scatterplot instance was initialized when the mouse was already over the canvas element, the mouse enter handler would never fire and isMouseInCanvas would never be set to true. That prevented hover effects from working.

This PR fixes this by checking which elements the mouse is hovering on the initial mouse move event.

Why is it necessary?

Fixes #112

Checklist

flekschas commented 1 year ago

Thanks for testing @NOT-HAL9000