@uimaxbai/am-lyrics 1.2.6 → 1.2.7

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,17 +322,17 @@ class GoogleService {
322
322
  }
323
323
  }
324
324
 
325
- const VERSION = '1.2.6';
325
+ const VERSION = '1.2.7';
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
+ const PRE_SCROLL_LEAD_SHORT_MS = 350;
331
331
  const SCROLL_ANIMATION_DURATION_MS = 280;
332
332
  const SCROLL_DELAY_INCREMENT_MS = 24;
333
333
  const GAP_PULSE_DURATION_MS = 4000;
334
334
  const GAP_PULSE_CYCLE_MS = GAP_PULSE_DURATION_MS * 2;
335
- const GAP_EXIT_LEAD_MS = 360;
335
+ const GAP_EXIT_LEAD_MS = 600;
336
336
  const GAP_MIN_SCALE = 0.85;
337
337
  /**
338
338
  * Fetch with an automatic timeout via AbortSignal.
@@ -1920,7 +1920,7 @@ let AmLyrics$1 = class AmLyrics extends i {
1920
1920
  }
1921
1921
  this.clearPreActiveClasses(i);
1922
1922
  const slowScrollDuration = Math.max(SCROLL_ANIMATION_DURATION_MS, timeUntilStart);
1923
- this.focusLine(nextLineEl, false, slowScrollDuration, !!currentGap);
1923
+ this.focusLine(nextLineEl, false, isBackToBack ? 500 : slowScrollDuration);
1924
1924
  }
1925
1925
  break;
1926
1926
  }
@@ -2726,42 +2726,19 @@ let AmLyrics$1 = class AmLyrics extends i {
2726
2726
  // Use a Map to collect animations like YouLyPlus
2727
2727
  const charAnimationsMap = new Map();
2728
2728
  const styleUpdates = [];
2729
- // Step 1 & 2: Apply animations
2729
+ // Step 1: Grow Pass
2730
2730
  if (isGrowable && isFirstSyllable && allWordCharSpans.length > 0) {
2731
- // Glow AND wipe applied to ALL characters simultaneously from the first syllable
2732
- // This prevents CSS animation restarts because the `animation` property is set once.
2733
- const firstSyllableStartTime = parseFloat(syllable.getAttribute('data-start-time') || '0');
2734
- allWordCharSpans.forEach((span, charIndexInWord) => {
2731
+ const finalDuration = wordDurationMs;
2732
+ const baseDelayPerChar = finalDuration * 0.09;
2733
+ const growDurationMs = finalDuration * 1.5;
2734
+ allWordCharSpans.forEach(span => {
2735
2735
  const horizontalOffset = parseFloat(span.dataset.horizontalOffset || '0');
2736
2736
  const maxScale = span.dataset.maxScale || '1.1';
2737
2737
  const shadowIntensity = span.dataset.shadowIntensity || '0.6';
2738
2738
  const translateYPeak = span.dataset.translateYPeak || '-2';
2739
- const animationParts = [];
2740
- const parentSyllable = span.closest('.lyrics-syllable');
2741
- if (parentSyllable) {
2742
- const parentDuration = parseFloat(parentSyllable.getAttribute('data-duration') || '0');
2743
- const parentStartTime = parseFloat(parentSyllable.getAttribute('data-start-time') || '0');
2744
- const startPct = parseFloat(span.dataset.wipeStart || '0');
2745
- const durationPct = parseFloat(span.dataset.wipeDuration || '0');
2746
- const relativeStartOffset = Math.max(0, parentStartTime - firstSyllableStartTime);
2747
- const wipeDelay = relativeStartOffset + parentDuration * startPct;
2748
- const wipeDuration = parentDuration * durationPct;
2749
- const useStartAnimation = isFirstInContainer && charIndexInWord === 0;
2750
- let charWipeAnimation = 'wipe';
2751
- if (useStartAnimation)
2752
- charWipeAnimation = isRTL ? 'start-wipe-rtl' : 'start-wipe';
2753
- else
2754
- charWipeAnimation = isRTL ? 'wipe-rtl' : 'wipe';
2755
- // Blend word and syllable durations to let the gradient flow smoothly
2756
- // while still responding to syllable pacing (no strict exactness, just natural flow)
2757
- const growDelay = wipeDelay;
2758
- const growDurationMs = Math.max(600, wordDurationMs * 0.8 + parentDuration * 1.5);
2759
- animationParts.push(`grow-dynamic ${growDurationMs}ms ease-in-out ${growDelay}ms forwards`);
2760
- if (wipeDuration > 0) {
2761
- animationParts.push(`${charWipeAnimation} ${wipeDuration}ms linear ${wipeDelay}ms forwards`);
2762
- }
2763
- }
2764
- charAnimationsMap.set(span, animationParts.join(', '));
2739
+ const syllableCharIndex = parseFloat(span.dataset.syllableCharIndex || '0');
2740
+ const growDelay = baseDelayPerChar * syllableCharIndex;
2741
+ charAnimationsMap.set(span, `grow-dynamic ${growDurationMs}ms ease-in-out ${growDelay}ms forwards`);
2765
2742
  styleUpdates.push({
2766
2743
  element: span,
2767
2744
  property: '--char-offset-x',
@@ -2784,26 +2761,8 @@ let AmLyrics$1 = class AmLyrics extends i {
2784
2761
  });
2785
2762
  });
2786
2763
  }
2787
- else if (isGrowable && !isFirstSyllable && charSpans.length > 0) {
2788
- // For subsequent syllables of a growable word:
2789
- // If they already have `grow-dynamic`, it means the first syllable correctly took care of BOTH grow and wipe!
2790
- // Otherwise, they scrubbed directly into this syllable, so let's at least do the wipe.
2791
- charSpans.forEach(span => {
2792
- const existingAnimation = charAnimationsMap.get(span) || span.style.animation || '';
2793
- if (existingAnimation.includes('grow-dynamic'))
2794
- return;
2795
- const startPct = parseFloat(span.dataset.wipeStart || '0');
2796
- const durationPct = parseFloat(span.dataset.wipeDuration || '0');
2797
- const wipeDelay = syllableDurationMs * startPct;
2798
- const wipeDuration = syllableDurationMs * durationPct;
2799
- const charWipeAnimation = isRTL ? 'wipe-rtl' : 'wipe';
2800
- if (wipeDuration > 0) {
2801
- charAnimationsMap.set(span, `${charWipeAnimation} ${wipeDuration}ms linear ${wipeDelay}ms forwards`);
2802
- }
2803
- });
2804
- }
2805
- else if (charSpans.length > 0) {
2806
- // Per-character wipe for non-growable words (matching YouLyPlus)
2764
+ // Step 2: Wipe Pass
2765
+ if (charSpans.length > 0) {
2807
2766
  charSpans.forEach((span, charIndex) => {
2808
2767
  const startPct = parseFloat(span.dataset.wipeStart || '0');
2809
2768
  const durationPct = parseFloat(span.dataset.wipeDuration || '0');
@@ -2817,8 +2776,26 @@ let AmLyrics$1 = class AmLyrics extends i {
2817
2776
  else {
2818
2777
  charWipeAnimation = isRTL ? 'wipe-rtl' : 'wipe';
2819
2778
  }
2779
+ const existingAnimation = charAnimationsMap.get(span) || span.style.animation || '';
2780
+ const animationParts = [];
2781
+ if (existingAnimation && existingAnimation.includes('grow-dynamic')) {
2782
+ animationParts.push(existingAnimation.split(',')[0].trim());
2783
+ }
2784
+ if (charIndex > 0) {
2785
+ const arrivalTime = span.dataset.preWipeArrival
2786
+ ? parseFloat(span.dataset.preWipeArrival)
2787
+ : wipeDelay;
2788
+ const constantDuration = parseFloat(span.dataset.preWipeDuration || '100');
2789
+ const animDelay = arrivalTime - constantDuration;
2790
+ if (constantDuration > 0) {
2791
+ animationParts.push(`pre-wipe-char ${constantDuration}ms linear ${animDelay}ms forwards`);
2792
+ }
2793
+ }
2820
2794
  if (wipeDuration > 0) {
2821
- charAnimationsMap.set(span, `${charWipeAnimation} ${wipeDuration}ms linear ${wipeDelay}ms forwards`);
2795
+ animationParts.push(`${charWipeAnimation} ${wipeDuration}ms linear ${wipeDelay}ms forwards`);
2796
+ }
2797
+ if (animationParts.length > 0) {
2798
+ charAnimationsMap.set(span, animationParts.join(', '));
2822
2799
  }
2823
2800
  });
2824
2801
  }
@@ -4654,8 +4631,8 @@ AmLyrics$1.styles = i$3 `
4654
4631
  0.75em 100%,
4655
4632
  0% 100%;
4656
4633
  background-position:
4657
- -0.375em 0%,
4658
- left;
4634
+ -0.75em 0%,
4635
+ -0.375em 0%;
4659
4636
  }
4660
4637
  100% {
4661
4638
  background-size:
@@ -4749,7 +4726,7 @@ AmLyrics$1.styles = i$3 `
4749
4726
  0.75em 100%,
4750
4727
  0% 100%;
4751
4728
  background-position:
4752
- -0.85em 0%,
4729
+ -0.75em 0%,
4753
4730
  left;
4754
4731
  }
4755
4732
  to {
@@ -4757,7 +4734,7 @@ AmLyrics$1.styles = i$3 `
4757
4734
  0.75em 100%,
4758
4735
  0% 100%;
4759
4736
  background-position:
4760
- -0.85em 0%,
4737
+ -0.375em 0%,
4761
4738
  left;
4762
4739
  }
4763
4740
  }