@uimaxbai/am-lyrics 1.2.3 → 1.2.4

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