@uimaxbai/am-lyrics 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/react.js CHANGED
@@ -322,11 +322,12 @@ class GoogleService {
322
322
  }
323
323
  }
324
324
 
325
- const VERSION = '1.2.5';
325
+ const VERSION = '1.2.6';
326
326
  const INSTRUMENTAL_THRESHOLD_MS = 7000; // Show dots for gaps >= 7s
327
327
  const FETCH_TIMEOUT_MS = 8000; // Timeout for all lyrics fetch requests
328
328
  const SEEK_THRESHOLD_MS = 500;
329
329
  const PRE_SCROLL_LEAD_MS = 500;
330
+ const PRE_SCROLL_LEAD_SHORT_MS = 150;
330
331
  const SCROLL_ANIMATION_DURATION_MS = 280;
331
332
  const SCROLL_DELAY_INCREMENT_MS = 24;
332
333
  const GAP_PULSE_DURATION_MS = 4000;
@@ -1902,12 +1903,21 @@ let AmLyrics$1 = class AmLyrics extends i {
1902
1903
  const line = this.lyrics[i];
1903
1904
  const timeUntilStart = line.timestamp - newTime;
1904
1905
  const nextLineEl = this.lyricsContainer.querySelector(`#lyrics-line-${i}`);
1905
- if (timeUntilStart > 0 && timeUntilStart <= PRE_SCROLL_LEAD_MS) {
1906
+ const isBackToBack = this.activeLineIndices.length > 0;
1907
+ const leadTime = isBackToBack
1908
+ ? PRE_SCROLL_LEAD_SHORT_MS
1909
+ : PRE_SCROLL_LEAD_MS;
1910
+ if (timeUntilStart > leadTime) {
1911
+ break; // Lines are ordered by timestamp, no need to check further
1912
+ }
1913
+ if (timeUntilStart > 0 && timeUntilStart <= leadTime) {
1906
1914
  // Time to pre-scroll and pre-activate!
1907
1915
  if (nextLineEl) {
1908
- // Apply unblur & zoom effect ahead of lyric start
1909
1916
  preActiveLineIndex = i;
1910
- nextLineEl.classList.add('pre-active');
1917
+ if (!isBackToBack) {
1918
+ // Apply unblur & zoom effect ahead of lyric start only if no line is currently active
1919
+ nextLineEl.classList.add('pre-active');
1920
+ }
1911
1921
  this.clearPreActiveClasses(i);
1912
1922
  const slowScrollDuration = Math.max(SCROLL_ANIMATION_DURATION_MS, timeUntilStart);
1913
1923
  this.focusLine(nextLineEl, false, slowScrollDuration, !!currentGap);