ryohey / signal

Online MIDI Editor: signal
https://signal.vercel.app
MIT License
1.25k stars 140 forks source link

Piano Roll horizontal scroll bar - broken scrolling behavior #382

Closed robertnhart closed 1 month ago

robertnhart commented 1 month ago

Describe the bug After a recent update, on the Piano Roll page, the horizontal scroll bar thumb box is always small. Dragging the thumb box produces strange scrolling behavior, going to large measure numbers quickly.

Previously, the Piano Roll horizontal scroll bar thumb box started out large for a new empty file, it would gradually shrink as new content was added, and dragging it would scroll normally.

To Reproduce

Expected behavior Restore normal horizontal scrolling function. I have found the cause and will submit a pull request.

robertnhart commented 1 month ago

In various places, math like the following is used to convert amounts from pixels to ticks or from ticks to pixels:

pixels / pixelsPerTick = ticks ticks * pixelsPerTick = pixels

In a recent update, these math expressions were moved into their own functions:

transform.getTick(pixels) = ticks transform.getX(ticks) = pixels

I found a spot in file PianoRollStore.ts, function get contentWidth() that was converting a tick value to a tick again:

return transform.getTick(Math.max(trackEndTick, endTick))

I corrected it to getX which converts ticks to pixels:

return transform.getX(Math.max(trackEndTick, endTick))