@uimaxbai/am-lyrics 1.2.4 → 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.4';
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;
@@ -1897,29 +1898,34 @@ let AmLyrics$1 = class AmLyrics extends i {
1897
1898
  !this.isUserScrolling &&
1898
1899
  !this.isClickSeeking &&
1899
1900
  this.lyrics) {
1900
- // Condition: ONLY pre-scroll if no other lyric is currently playing.
1901
- // If a lyric is playing, we must wait for it to finish (handled by updated()).
1902
- if (this.activeLineIndices.length === 0) {
1903
- let preActiveLineIndex = null;
1904
- for (let i = 0; i < this.lyrics.length; i += 1) {
1905
- const line = this.lyrics[i];
1906
- const timeUntilStart = line.timestamp - newTime;
1907
- const nextLineEl = this.lyricsContainer.querySelector(`#lyrics-line-${i}`);
1908
- if (timeUntilStart > 0 && timeUntilStart <= PRE_SCROLL_LEAD_MS) {
1909
- // Time to pre-scroll and pre-activate!
1910
- if (nextLineEl) {
1911
- // Apply unblur & zoom effect ahead of lyric start
1912
- preActiveLineIndex = i;
1901
+ let preActiveLineIndex = null;
1902
+ for (let i = 0; i < this.lyrics.length; i += 1) {
1903
+ const line = this.lyrics[i];
1904
+ const timeUntilStart = line.timestamp - newTime;
1905
+ const nextLineEl = this.lyricsContainer.querySelector(`#lyrics-line-${i}`);
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) {
1914
+ // Time to pre-scroll and pre-activate!
1915
+ if (nextLineEl) {
1916
+ preActiveLineIndex = i;
1917
+ if (!isBackToBack) {
1918
+ // Apply unblur & zoom effect ahead of lyric start only if no line is currently active
1913
1919
  nextLineEl.classList.add('pre-active');
1914
- this.clearPreActiveClasses(i);
1915
- const slowScrollDuration = Math.max(SCROLL_ANIMATION_DURATION_MS, timeUntilStart);
1916
- this.focusLine(nextLineEl, false, slowScrollDuration, !!currentGap);
1917
1920
  }
1918
- break;
1921
+ this.clearPreActiveClasses(i);
1922
+ const slowScrollDuration = Math.max(SCROLL_ANIMATION_DURATION_MS, timeUntilStart);
1923
+ this.focusLine(nextLineEl, false, slowScrollDuration, !!currentGap);
1919
1924
  }
1925
+ break;
1920
1926
  }
1921
- this.clearPreActiveClasses(preActiveLineIndex);
1922
1927
  }
1928
+ this.clearPreActiveClasses(preActiveLineIndex);
1923
1929
  }
1924
1930
  }
1925
1931
  }