@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/src/AmLyrics.ts CHANGED
@@ -2,17 +2,17 @@ import { css, html, LitElement, svg } from 'lit';
2
2
  import { property, query, state } from 'lit/decorators.js';
3
3
  import { GoogleService } from './GoogleService.js';
4
4
 
5
- const VERSION = '1.2.6';
5
+ const VERSION = '1.2.7';
6
6
  const INSTRUMENTAL_THRESHOLD_MS = 7000; // Show dots for gaps >= 7s
7
7
  const FETCH_TIMEOUT_MS = 8000; // Timeout for all lyrics fetch requests
8
8
  const SEEK_THRESHOLD_MS = 500;
9
9
  const PRE_SCROLL_LEAD_MS = 500;
10
- const PRE_SCROLL_LEAD_SHORT_MS = 150;
10
+ const PRE_SCROLL_LEAD_SHORT_MS = 350;
11
11
  const SCROLL_ANIMATION_DURATION_MS = 280;
12
12
  const SCROLL_DELAY_INCREMENT_MS = 24;
13
13
  const GAP_PULSE_DURATION_MS = 4000;
14
14
  const GAP_PULSE_CYCLE_MS = GAP_PULSE_DURATION_MS * 2;
15
- const GAP_EXIT_LEAD_MS = 360;
15
+ const GAP_EXIT_LEAD_MS = 600;
16
16
  const GAP_MIN_SCALE = 0.85;
17
17
 
18
18
  /**
@@ -1010,8 +1010,8 @@ export class AmLyrics extends LitElement {
1010
1010
  0.75em 100%,
1011
1011
  0% 100%;
1012
1012
  background-position:
1013
- -0.375em 0%,
1014
- left;
1013
+ -0.75em 0%,
1014
+ -0.375em 0%;
1015
1015
  }
1016
1016
  100% {
1017
1017
  background-size:
@@ -1105,7 +1105,7 @@ export class AmLyrics extends LitElement {
1105
1105
  0.75em 100%,
1106
1106
  0% 100%;
1107
1107
  background-position:
1108
- -0.85em 0%,
1108
+ -0.75em 0%,
1109
1109
  left;
1110
1110
  }
1111
1111
  to {
@@ -1113,7 +1113,7 @@ export class AmLyrics extends LitElement {
1113
1113
  0.75em 100%,
1114
1114
  0% 100%;
1115
1115
  background-position:
1116
- -0.85em 0%,
1116
+ -0.375em 0%,
1117
1117
  left;
1118
1118
  }
1119
1119
  }
@@ -3302,8 +3302,7 @@ export class AmLyrics extends LitElement {
3302
3302
  this.focusLine(
3303
3303
  nextLineEl,
3304
3304
  false,
3305
- slowScrollDuration,
3306
- !!currentGap,
3305
+ isBackToBack ? 500 : slowScrollDuration,
3307
3306
  );
3308
3307
  }
3309
3308
  break;
@@ -4344,71 +4343,29 @@ export class AmLyrics extends LitElement {
4344
4343
  value: string;
4345
4344
  }> = [];
4346
4345
 
4347
- // Step 1 & 2: Apply animations
4346
+ // Step 1: Grow Pass
4348
4347
  if (isGrowable && isFirstSyllable && allWordCharSpans.length > 0) {
4349
- // Glow AND wipe applied to ALL characters simultaneously from the first syllable
4350
- // This prevents CSS animation restarts because the `animation` property is set once.
4351
-
4352
- const firstSyllableStartTime = parseFloat(
4353
- syllable.getAttribute('data-start-time') || '0',
4354
- );
4348
+ const finalDuration = wordDurationMs;
4349
+ const baseDelayPerChar = finalDuration * 0.09;
4350
+ const growDurationMs = finalDuration * 1.5;
4355
4351
 
4356
- allWordCharSpans.forEach((span, charIndexInWord) => {
4352
+ allWordCharSpans.forEach(span => {
4357
4353
  const horizontalOffset = parseFloat(
4358
4354
  span.dataset.horizontalOffset || '0',
4359
4355
  );
4360
-
4361
4356
  const maxScale = span.dataset.maxScale || '1.1';
4362
4357
  const shadowIntensity = span.dataset.shadowIntensity || '0.6';
4363
4358
  const translateYPeak = span.dataset.translateYPeak || '-2';
4364
4359
 
4365
- const animationParts: string[] = [];
4366
-
4367
- const parentSyllable = span.closest('.lyrics-syllable');
4368
- if (parentSyllable) {
4369
- const parentDuration = parseFloat(
4370
- parentSyllable.getAttribute('data-duration') || '0',
4371
- );
4372
- const parentStartTime = parseFloat(
4373
- parentSyllable.getAttribute('data-start-time') || '0',
4374
- );
4375
-
4376
- const startPct = parseFloat(span.dataset.wipeStart || '0');
4377
- const durationPct = parseFloat(span.dataset.wipeDuration || '0');
4378
-
4379
- const relativeStartOffset = Math.max(
4380
- 0,
4381
- parentStartTime - firstSyllableStartTime,
4382
- );
4383
- const wipeDelay = relativeStartOffset + parentDuration * startPct;
4384
- const wipeDuration = parentDuration * durationPct;
4385
-
4386
- const useStartAnimation = isFirstInContainer && charIndexInWord === 0;
4387
- let charWipeAnimation = 'wipe';
4388
- if (useStartAnimation)
4389
- charWipeAnimation = isRTL ? 'start-wipe-rtl' : 'start-wipe';
4390
- else charWipeAnimation = isRTL ? 'wipe-rtl' : 'wipe';
4391
-
4392
- // Blend word and syllable durations to let the gradient flow smoothly
4393
- // while still responding to syllable pacing (no strict exactness, just natural flow)
4394
- const growDelay = wipeDelay;
4395
- const growDurationMs = Math.max(
4396
- 600,
4397
- wordDurationMs * 0.8 + parentDuration * 1.5,
4398
- );
4399
-
4400
- animationParts.push(
4401
- `grow-dynamic ${growDurationMs}ms ease-in-out ${growDelay}ms forwards`,
4402
- );
4403
-
4404
- if (wipeDuration > 0) {
4405
- animationParts.push(
4406
- `${charWipeAnimation} ${wipeDuration}ms linear ${wipeDelay}ms forwards`,
4407
- );
4408
- }
4409
- }
4360
+ const syllableCharIndex = parseFloat(
4361
+ span.dataset.syllableCharIndex || '0',
4362
+ );
4363
+ const growDelay = baseDelayPerChar * syllableCharIndex;
4410
4364
 
4411
- charAnimationsMap.set(span, animationParts.join(', '));
4365
+ charAnimationsMap.set(
4366
+ span,
4367
+ `grow-dynamic ${growDurationMs}ms ease-in-out ${growDelay}ms forwards`,
4368
+ );
4412
4369
 
4413
4370
  styleUpdates.push({
4414
4371
  element: span,
@@ -4431,31 +4388,10 @@ export class AmLyrics extends LitElement {
4431
4388
  value: `${translateYPeak}`,
4432
4389
  });
4433
4390
  });
4434
- } else if (isGrowable && !isFirstSyllable && charSpans.length > 0) {
4435
- // For subsequent syllables of a growable word:
4436
- // If they already have `grow-dynamic`, it means the first syllable correctly took care of BOTH grow and wipe!
4437
- // Otherwise, they scrubbed directly into this syllable, so let's at least do the wipe.
4438
- charSpans.forEach(span => {
4439
- const existingAnimation =
4440
- charAnimationsMap.get(span) || span.style.animation || '';
4441
- if (existingAnimation.includes('grow-dynamic')) return;
4442
-
4443
- const startPct = parseFloat(span.dataset.wipeStart || '0');
4444
- const durationPct = parseFloat(span.dataset.wipeDuration || '0');
4445
- const wipeDelay = syllableDurationMs * startPct;
4446
- const wipeDuration = syllableDurationMs * durationPct;
4447
-
4448
- const charWipeAnimation = isRTL ? 'wipe-rtl' : 'wipe';
4391
+ }
4449
4392
 
4450
- if (wipeDuration > 0) {
4451
- charAnimationsMap.set(
4452
- span,
4453
- `${charWipeAnimation} ${wipeDuration}ms linear ${wipeDelay}ms forwards`,
4454
- );
4455
- }
4456
- });
4457
- } else if (charSpans.length > 0) {
4458
- // Per-character wipe for non-growable words (matching YouLyPlus)
4393
+ // Step 2: Wipe Pass
4394
+ if (charSpans.length > 0) {
4459
4395
  charSpans.forEach((span, charIndex) => {
4460
4396
  const startPct = parseFloat(span.dataset.wipeStart || '0');
4461
4397
  const durationPct = parseFloat(span.dataset.wipeDuration || '0');
@@ -4471,12 +4407,39 @@ export class AmLyrics extends LitElement {
4471
4407
  charWipeAnimation = isRTL ? 'wipe-rtl' : 'wipe';
4472
4408
  }
4473
4409
 
4410
+ const existingAnimation =
4411
+ charAnimationsMap.get(span) || span.style.animation || '';
4412
+
4413
+ const animationParts = [];
4414
+
4415
+ if (existingAnimation && existingAnimation.includes('grow-dynamic')) {
4416
+ animationParts.push(existingAnimation.split(',')[0].trim());
4417
+ }
4418
+ if (charIndex > 0) {
4419
+ const arrivalTime = span.dataset.preWipeArrival
4420
+ ? parseFloat(span.dataset.preWipeArrival)
4421
+ : wipeDelay;
4422
+ const constantDuration = parseFloat(
4423
+ span.dataset.preWipeDuration || '100',
4424
+ );
4425
+ const animDelay = arrivalTime - constantDuration;
4426
+
4427
+ if (constantDuration > 0) {
4428
+ animationParts.push(
4429
+ `pre-wipe-char ${constantDuration}ms linear ${animDelay}ms forwards`,
4430
+ );
4431
+ }
4432
+ }
4433
+
4474
4434
  if (wipeDuration > 0) {
4475
- charAnimationsMap.set(
4476
- span,
4435
+ animationParts.push(
4477
4436
  `${charWipeAnimation} ${wipeDuration}ms linear ${wipeDelay}ms forwards`,
4478
4437
  );
4479
4438
  }
4439
+
4440
+ if (animationParts.length > 0) {
4441
+ charAnimationsMap.set(span, animationParts.join(', '));
4442
+ }
4480
4443
  });
4481
4444
  } else {
4482
4445
  // Syllable-level wipe for regular (non-growable) words without chars