Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixing in getting mouse position for issue #27. #68

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

PhilJollans
Copy link

Second attempt to fix mouse events.

Do not apply the bottom border to hoverDiv. The bottom border was calculated once only, and is likely to be incorrect if the browser window is resized. However, this change means that the hoverDiv is larger than necessary.

To counter this problem getPositionFromMouseCoords now has the return type Position|undefined and returns undefined if the mouse position is outside the fretboard by more than half the string separation.

The calculation in getPositionFromMouseCoords has been simplified. It is now relative only to the stringsGroup and does not rely on the topPadding or LeftPadding.

I have made two changes:
 - pass topPadding into the function and subtract it from the Y position
 - compare the Y coordinate to 0.5, 1.5, ... times the string separation

Previously, the Y coordinate was compared to 1, 2, ... times the separation.
I think this only worked, when topPadding was approximately half of the string separation.
Do not apply the bottom border to `hoverDiv`. The bottom border was calculated once only, and is likely to be incorrect if the browser window is resized. However, this change means that the `hoverDiv` is larger than necessary.

To counter this problem `getPositionFromMouseCoords` now has the return type `Position|undefined` and returns undefined if the mouse position is outside the fretboard by more than half the string separation.

The calculation in `getPositionFromMouseCoords` has been simplified. It is now relative only to the stringsGroup and does not rely on the topPadding or LeftPadding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant