Ewan Claude Opus 4.6 commited on
Commit
57d692f
·
1 Parent(s): f3e5cc5

Smooth progress line movement on sheet music

Browse files

CSS transition on left/top for smooth motion within a staff line.
Transition disabled on line jumps so it snaps instantly to the new line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

app/src/components/SheetMusic.jsx CHANGED
@@ -202,6 +202,7 @@ export default function SheetMusic({ midiObject, fileName, currentTimeRef, isPla
202
  if (!progressEl || !scrollEl) return;
203
 
204
  let lastColoredBeat = -1;
 
205
 
206
  const tick = () => {
207
  const currentTime = currentTimeRef?.current ?? 0;
@@ -240,6 +241,14 @@ export default function SheetMusic({ midiObject, fileName, currentTimeRef, isPla
240
  const lineY = mLayout.y - 5;
241
  const lineHeight = BASS_Y_OFFSET + 80; // span treble + bass staves
242
 
 
 
 
 
 
 
 
 
243
  progressEl.style.display = 'block';
244
  progressEl.style.left = `${lineX + 20}px`; // +20 for container padding
245
  progressEl.style.top = `${lineY + 20}px`;
 
202
  if (!progressEl || !scrollEl) return;
203
 
204
  let lastColoredBeat = -1;
205
+ let lastLineIdx = -1;
206
 
207
  const tick = () => {
208
  const currentTime = currentTimeRef?.current ?? 0;
 
241
  const lineY = mLayout.y - 5;
242
  const lineHeight = BASS_Y_OFFSET + 80; // span treble + bass staves
243
 
244
+ // Enable smooth transition within the same staff line, disable on line jumps
245
+ if (mLayout.lineIdx !== lastLineIdx) {
246
+ progressEl.classList.remove('smooth');
247
+ } else {
248
+ progressEl.classList.add('smooth');
249
+ }
250
+ lastLineIdx = mLayout.lineIdx;
251
+
252
  progressEl.style.display = 'block';
253
  progressEl.style.left = `${lineX + 20}px`; // +20 for container padding
254
  progressEl.style.top = `${lineY + 20}px`;
app/src/index.css CHANGED
@@ -742,6 +742,10 @@ input[type='range']::-moz-range-thumb {
742
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
743
  }
744
 
 
 
 
 
745
  .sheet-music-empty {
746
  flex: 1;
747
  display: flex;
 
742
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
743
  }
744
 
745
+ .sheet-music-progress-line.smooth {
746
+ transition: left 0.12s linear, top 0.12s linear;
747
+ }
748
+
749
  .sheet-music-empty {
750
  flex: 1;
751
  display: flex;