@uimaxbai/am-lyrics 1.2.3 → 1.2.5

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,7 +322,7 @@ class GoogleService {
322
322
  }
323
323
  }
324
324
 
325
- const VERSION = '1.2.3';
325
+ const VERSION = '1.2.5';
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;
@@ -1897,28 +1897,25 @@ let AmLyrics$1 = class AmLyrics extends i {
1897
1897
  !this.isUserScrolling &&
1898
1898
  !this.isClickSeeking &&
1899
1899
  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;
1913
- nextLineEl.classList.add('pre-active');
1914
- this.clearPreActiveClasses(i);
1915
- this.focusLine(nextLineEl);
1916
- }
1917
- break;
1900
+ let preActiveLineIndex = null;
1901
+ for (let i = 0; i < this.lyrics.length; i += 1) {
1902
+ const line = this.lyrics[i];
1903
+ const timeUntilStart = line.timestamp - newTime;
1904
+ const nextLineEl = this.lyricsContainer.querySelector(`#lyrics-line-${i}`);
1905
+ if (timeUntilStart > 0 && timeUntilStart <= PRE_SCROLL_LEAD_MS) {
1906
+ // Time to pre-scroll and pre-activate!
1907
+ if (nextLineEl) {
1908
+ // Apply unblur & zoom effect ahead of lyric start
1909
+ preActiveLineIndex = i;
1910
+ nextLineEl.classList.add('pre-active');
1911
+ this.clearPreActiveClasses(i);
1912
+ const slowScrollDuration = Math.max(SCROLL_ANIMATION_DURATION_MS, timeUntilStart);
1913
+ this.focusLine(nextLineEl, false, slowScrollDuration, !!currentGap);
1918
1914
  }
1915
+ break;
1919
1916
  }
1920
- this.clearPreActiveClasses(preActiveLineIndex);
1921
1917
  }
1918
+ this.clearPreActiveClasses(preActiveLineIndex);
1922
1919
  }
1923
1920
  }
1924
1921
  }
@@ -2106,18 +2103,19 @@ let AmLyrics$1 = class AmLyrics extends i {
2106
2103
  }
2107
2104
  return candidateIndex;
2108
2105
  }
2109
- focusLine(lineElement, forceScroll = false) {
2106
+ focusLine(lineElement, forceScroll = false, scrollDuration = undefined, skipScroll = false) {
2110
2107
  const primaryChanged = lineElement !== this.currentPrimaryActiveLine;
2111
2108
  if (primaryChanged) {
2112
2109
  this.lastPrimaryActiveLine = this.currentPrimaryActiveLine;
2113
2110
  this.currentPrimaryActiveLine = lineElement;
2114
2111
  }
2115
2112
  this.updatePositionClasses(lineElement);
2116
- if ((forceScroll || primaryChanged) &&
2113
+ if (!skipScroll &&
2114
+ (forceScroll || primaryChanged) &&
2117
2115
  this.autoScroll &&
2118
2116
  !this.isUserScrolling &&
2119
2117
  !this.isClickSeeking) {
2120
- this.scrollToActiveLineYouLy(lineElement, forceScroll);
2118
+ this.scrollToActiveLineYouLy(lineElement, forceScroll, scrollDuration);
2121
2119
  }
2122
2120
  }
2123
2121
  handleUserScroll() {
@@ -2490,7 +2488,7 @@ let AmLyrics$1 = class AmLyrics extends i {
2490
2488
  /**
2491
2489
  * Animate scroll with staggered delay for smooth YouLyPlus-style scrolling
2492
2490
  */
2493
- animateScrollYouLy(newTranslateY, forceScroll = false) {
2491
+ animateScrollYouLy(newTranslateY, forceScroll = false, scrollDuration = undefined) {
2494
2492
  if (!this.lyricsContainer)
2495
2493
  return;
2496
2494
  const parent = this.lyricsContainer;
@@ -2571,11 +2569,12 @@ let AmLyrics$1 = class AmLyrics extends i {
2571
2569
  if (i >= referenceIndex)
2572
2570
  delayCounter += 1;
2573
2571
  const delay = i >= referenceIndex ? (delayCounter - 1) * delayIncrement : 0;
2572
+ const duration = scrollDuration ?? SCROLL_ANIMATION_DURATION_MS;
2574
2573
  line.style.setProperty('--scroll-delta', `${delta}px`);
2575
2574
  line.style.setProperty('--lyrics-line-delay', `${delay}ms`);
2576
- line.style.setProperty('--scroll-duration', `${SCROLL_ANIMATION_DURATION_MS}ms`);
2575
+ line.style.setProperty('--scroll-duration', `${duration}ms`);
2577
2576
  newAnimatingLines.push(line);
2578
- const lineDuration = SCROLL_ANIMATION_DURATION_MS + delay;
2577
+ const lineDuration = duration + delay;
2579
2578
  if (lineDuration > maxAnimationDuration) {
2580
2579
  maxAnimationDuration = lineDuration;
2581
2580
  }
@@ -2590,13 +2589,13 @@ let AmLyrics$1 = class AmLyrics extends i {
2590
2589
  animatingLines.push(line);
2591
2590
  }
2592
2591
  animState.isAnimating = true;
2593
- const BASE_DURATION = SCROLL_ANIMATION_DURATION_MS;
2592
+ const BASE_DURATION = scrollDuration ?? SCROLL_ANIMATION_DURATION_MS;
2594
2593
  this.scrollUnlockTimeout = setTimeout(() => {
2595
2594
  animState.isAnimating = false;
2596
2595
  if (animState.pendingUpdate !== null) {
2597
2596
  const pendingValue = animState.pendingUpdate;
2598
2597
  animState.pendingUpdate = null;
2599
- this.animateScrollYouLy(pendingValue, false);
2598
+ this.animateScrollYouLy(pendingValue, false, scrollDuration);
2600
2599
  }
2601
2600
  }, BASE_DURATION);
2602
2601
  this.scrollAnimationTimeout = setTimeout(() => {
@@ -2657,7 +2656,7 @@ let AmLyrics$1 = class AmLyrics extends i {
2657
2656
  /**
2658
2657
  * Scroll to active line with YouLyPlus-style animation
2659
2658
  */
2660
- scrollToActiveLineYouLy(activeLine, forceScroll = false) {
2659
+ scrollToActiveLineYouLy(activeLine, forceScroll = false, scrollDuration = undefined) {
2661
2660
  if (!activeLine || !this.lyricsContainer)
2662
2661
  return;
2663
2662
  const paddingTop = this.getScrollPaddingTop();
@@ -2685,10 +2684,11 @@ let AmLyrics$1 = class AmLyrics extends i {
2685
2684
  clearTimeout(this.userScrollTimeoutId);
2686
2685
  this.userScrollTimeoutId = undefined;
2687
2686
  }
2687
+ const duration = scrollDuration ?? SCROLL_ANIMATION_DURATION_MS;
2688
2688
  setTimeout(() => {
2689
2689
  this.isProgrammaticScroll = false;
2690
- }, SCROLL_ANIMATION_DURATION_MS + 160);
2691
- this.animateScrollYouLy(targetTranslateY, forceScroll);
2690
+ }, duration + 160);
2691
+ this.animateScrollYouLy(targetTranslateY, forceScroll, scrollDuration);
2692
2692
  }
2693
2693
  /**
2694
2694
  * Update syllable highlight animation - apply CSS wipe animation
@@ -3324,13 +3324,13 @@ let AmLyrics$1 = class AmLyrics extends i {
3324
3324
  }
3325
3325
  else {
3326
3326
  isGrowableVW =
3327
- combinedDuration >= 900 && combinedDuration >= wordLen * 300;
3327
+ combinedDuration >= 850 && combinedDuration >= wordLen * 200;
3328
3328
  }
3329
3329
  }
3330
3330
  // Glow requirement (more strict)
3331
3331
  const isGlowingVW = isGrowableVW &&
3332
- combinedDuration >= 1200 &&
3333
- combinedDuration >= combinedText.length * 300;
3332
+ combinedDuration >= 1000 &&
3333
+ combinedDuration >= combinedText.length * 250;
3334
3334
  let charOff = 0;
3335
3335
  for (let gi = vwStart; gi <= vwEnd; gi += 1) {
3336
3336
  groupGrowable[gi] = isGrowableVW;
@@ -3900,14 +3900,16 @@ AmLyrics$1.styles = i$3 `
3900
3900
 
3901
3901
  .background-vocal-container {
3902
3902
  max-height: 0;
3903
- padding-top: 0.2em;
3903
+ padding-top: 0;
3904
+ transform: translateY(-0.5em) scale(0.95);
3904
3905
  overflow: visible;
3905
3906
  opacity: 0;
3906
3907
  font-size: var(--lyplus-font-size-subtext);
3907
3908
  transition:
3908
- max-height 350ms cubic-bezier(0.33, 1, 0.68, 1),
3909
- opacity 300ms ease-out,
3910
- padding 350ms cubic-bezier(0.33, 1, 0.68, 1);
3909
+ max-height 450ms cubic-bezier(0.33, 1, 0.68, 1),
3910
+ opacity 400ms ease-out,
3911
+ transform 450ms cubic-bezier(0.33, 1, 0.68, 1),
3912
+ padding 450ms cubic-bezier(0.33, 1, 0.68, 1);
3911
3913
  margin: 0;
3912
3914
  }
3913
3915
 
@@ -3915,11 +3917,14 @@ AmLyrics$1.styles = i$3 `
3915
3917
  .lyrics-line.pre-active .background-vocal-container {
3916
3918
  max-height: 4em;
3917
3919
  opacity: 1;
3920
+ padding-top: 0.2em;
3921
+ transform: translateY(0) scale(1);
3918
3922
  transition:
3919
- max-height 350ms cubic-bezier(0.22, 1, 0.36, 1),
3920
- opacity 300ms ease-out,
3921
- padding 350ms cubic-bezier(0.22, 1, 0.36, 1);
3922
- will-change: max-height, opacity, padding;
3923
+ max-height 450ms cubic-bezier(0.22, 1, 0.36, 1),
3924
+ opacity 400ms ease-out,
3925
+ transform 450ms cubic-bezier(0.22, 1, 0.36, 1),
3926
+ padding 450ms cubic-bezier(0.22, 1, 0.36, 1);
3927
+ will-change: max-height, opacity, padding, transform;
3923
3928
  }
3924
3929
 
3925
3930
  /* --- Line States & Modifiers --- */
@@ -4251,49 +4256,35 @@ AmLyrics$1.styles = i$3 `
4251
4256
  INSTRUMENTAL GAP STYLES
4252
4257
  ========================================================================== */
4253
4258
  .lyrics-gap {
4254
- max-height: 0;
4255
- padding: 0 var(--lyplus-padding-gap);
4256
- overflow: hidden;
4259
+ max-height: 1.6em;
4260
+ padding: var(--lyplus-padding-gap);
4261
+ overflow: visible;
4257
4262
  opacity: 0;
4258
4263
  box-sizing: content-box;
4259
4264
  background-clip: unset;
4260
4265
  transform-origin: top;
4261
4266
  transition:
4262
- padding 220ms cubic-bezier(0.33, 1, 0.68, 1),
4263
- max-height 220ms cubic-bezier(0.33, 1, 0.68, 1),
4264
4267
  opacity 160ms ease-out,
4265
4268
  transform var(--scroll-duration, 280ms) var(--lyrics-line-delay, 0ms);
4266
4269
  }
4267
4270
 
4268
4271
  .lyrics-gap.active {
4269
- max-height: 1.6em;
4270
- padding: var(--lyplus-padding-gap);
4271
4272
  opacity: 1;
4272
- overflow: visible;
4273
4273
  transition:
4274
- padding 220ms cubic-bezier(0.22, 1, 0.36, 1),
4275
- max-height 220ms cubic-bezier(0.22, 1, 0.36, 1),
4276
4274
  opacity 160ms ease-out,
4277
4275
  transform var(--scroll-duration, 280ms);
4278
- will-change: max-height, opacity, padding;
4276
+ will-change: opacity;
4279
4277
  }
4280
4278
 
4281
4279
  /* Exiting state: quickly collapse width and height so dots don't distort page, or remove max-height transition */
4282
4280
  .lyrics-gap.gap-exiting {
4283
- max-height: 0;
4284
- padding: 0 var(--lyplus-padding-gap);
4285
- opacity: 0;
4286
- overflow: visible;
4287
- transition:
4288
- padding var(--gap-exit-duration, 360ms) cubic-bezier(0.33, 1, 0.68, 1),
4289
- max-height var(--gap-exit-duration, 360ms)
4290
- cubic-bezier(0.33, 1, 0.68, 1),
4291
- opacity 160ms ease-out,
4292
- transform var(--scroll-duration, 280ms);
4281
+ opacity: 1;
4282
+ transition: transform var(--scroll-duration, 280ms);
4293
4283
  }
4294
4284
 
4295
4285
  .lyrics-gap .main-vocal-container {
4296
4286
  transform: translateY(-25%) scale(1) translateZ(0);
4287
+ transition: transform 400ms cubic-bezier(0.22, 1, 0.36, 1);
4297
4288
  }
4298
4289
 
4299
4290
  /* Jump animation plays during exit */