Skip to content

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

Open
PhilJollans wants to merge 17 commits intomoonwave99:masterfrom
PhilJollans:master
Open

Bug fixing in getting mouse position for issue #27.#68
PhilJollans wants to merge 17 commits intomoonwave99:masterfrom
PhilJollans:master

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.
@tdg5
Copy link

tdg5 commented Mar 9, 2025

I haven't used the fork related to this branch extensively, but there are definitely some bug fixes and nice additions 👍

…e nut.

This differs from '0', which just shows an open string.
Extend the setDots() method to fill the `note` property, if it is not already filled.
…rcent

Modify the function generateFrets to return pixel values.
Modify the usage of the frets array to use the values directly, without appending a % character.
Remove the scale transform from the 'fretboard-wrapper'
…d by the previous change,

which moved away from defining the fret positions in percent.
…y are rendered on top of the fret marker dots.

Handle in a similar manner to "dots".
Define a new method setMutedStrings, which can be called like setDots().
This makes it possible to mute strings without using the renderChord() method.
… into the `Options` structure:

  muteWidth: number;
  muteStrokeWidth: number;
  muteStrokeColor: string;

Add additional options:
  degreeBackgroundColor: string;
  degreeStrokeColor: string;

This allows flexibility for implementing dark and light modes (by specifying the colors using CSS variables).

Render the marker dots under the frets and strings. From about fret 17, the marker dots are in fact too big. :(
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.

2 participants