@dloizides/marketing-astro-kit 1.12.0 → 1.13.0

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +46 -0
  3. package/package.json +13 -6
  4. package/src/ContactCard.astro +107 -0
  5. package/src/contactCard/CardActions.astro +20 -0
  6. package/src/contactCard/CardBrand.astro +25 -0
  7. package/src/contactCard/CardContacts.astro +22 -0
  8. package/src/contactCard/CardContactsVariant.ts +5 -0
  9. package/src/contactCard/CardDialog.astro +16 -0
  10. package/src/contactCard/CardIcon.astro +12 -0
  11. package/src/contactCard/CardIconName.ts +6 -0
  12. package/src/contactCard/CardIdentity.astro +14 -0
  13. package/src/contactCard/CardLinkKind.ts +6 -0
  14. package/src/contactCard/CardPortrait.astro +14 -0
  15. package/src/contactCard/CardQr.astro +24 -0
  16. package/src/contactCard/CardSave.astro +43 -0
  17. package/src/contactCard/CardValues.astro +12 -0
  18. package/src/contactCard/ContactCardLayout.ts +7 -0
  19. package/src/contactCard/ContactPhotoType.ts +5 -0
  20. package/src/contactCard/InstallRoute.ts +6 -0
  21. package/src/contactCard/cardIcons.ts +11 -0
  22. package/src/contactCard/cardLinks.ts +43 -0
  23. package/src/contactCard/checks.ts +28 -0
  24. package/src/contactCard/chooseInstall.ts +21 -0
  25. package/src/contactCard/contactCard.css +69 -0
  26. package/src/contactCard/index.ts +16 -0
  27. package/src/contactCard/layouts.css +106 -0
  28. package/src/contactCard/manifest.ts +37 -0
  29. package/src/contactCard/motion/OpenMotion.ts +7 -0
  30. package/src/contactCard/motion/QrMotion.ts +7 -0
  31. package/src/contactCard/motion/SaveMotion.ts +7 -0
  32. package/src/contactCard/motion/TiltMotion.ts +7 -0
  33. package/src/contactCard/motion/beatTable.ts +144 -0
  34. package/src/contactCard/motion/beats.ts +43 -0
  35. package/src/contactCard/motion/cardMotion.ts +49 -0
  36. package/src/contactCard/motion/easings.ts +9 -0
  37. package/src/contactCard/motion/holdDuringOpen.ts +22 -0
  38. package/src/contactCard/motion/mountMotion.ts +26 -0
  39. package/src/contactCard/motion/mountOpenMark.ts +20 -0
  40. package/src/contactCard/motion/mountQrTurn.ts +86 -0
  41. package/src/contactCard/motion/mountSave.ts +26 -0
  42. package/src/contactCard/motion/mountTilt.ts +92 -0
  43. package/src/contactCard/motion/openCss.ts +18 -0
  44. package/src/contactCard/motion/parts.ts +25 -0
  45. package/src/contactCard/motion/playBeats.ts +21 -0
  46. package/src/contactCard/motion/sides.ts +33 -0
  47. package/src/contactCard/motion/tiltPose.ts +38 -0
  48. package/src/contactCard/motion.css +39 -0
  49. package/src/contactCard/mount.ts +76 -0
  50. package/src/contactCard/phone.ts +11 -0
  51. package/src/contactCard/qrSvg.ts +54 -0
  52. package/src/contactCard/types.ts +47 -0
  53. package/src/contactCard/vCard.ts +48 -0
  54. package/src/contactCard/vCardLines.ts +33 -0
  55. package/src/motionController/createMotionController.ts +11 -9
@@ -13,6 +13,7 @@ export interface MotionControllerOptions {
13
13
  watchReducedMotion?: boolean;
14
14
  forceStill?: () => boolean;
15
15
  canRun?: () => boolean;
16
+ signal?: AbortSignal;
16
17
  }
17
18
 
18
19
  export interface MotionController {
@@ -27,7 +28,7 @@ export function createMotionController(options: MotionControllerOptions): Motion
27
28
  const PAUSED = 'paused' as string as MotionState;
28
29
  const FIRST_FRAME_MS = 16;
29
30
  const MAX_FRAME_MS = 100;
30
- const { target, onFrame, onStill, onState, threshold = 0, watchReducedMotion = true, forceStill, canRun } = options;
31
+ const { target, onFrame, onStill, onState, threshold = 0, watchReducedMotion = true, forceStill, canRun, signal } = options;
31
32
  const reducedQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
32
33
  const reducedAtStart = reducedQuery.matches;
33
34
  let inView = true;
@@ -53,20 +54,21 @@ export function createMotionController(options: MotionControllerOptions): Motion
53
54
  const sync = (): void => {
54
55
  const state = getState();
55
56
  onState?.(state);
56
- if (state === RUNNING && canRun?.() !== false) {
57
+ if (state === RUNNING && canRun?.() !== false && signal?.aborted !== true) {
57
58
  if (!running) { running = true; frame = window.requestAnimationFrame(tick); }
58
59
  return;
59
60
  }
60
61
  stop();
61
62
  if (state === STILL) onStill?.();
62
63
  };
63
- if (watchReducedMotion) reducedQuery.addEventListener('change', sync);
64
- if (watchReducedMotion || !reducedAtStart) {
65
- document.addEventListener('visibilitychange', sync);
66
- if ('IntersectionObserver' in window) {
67
- new IntersectionObserver((entries) => { entries.forEach((entry) => { inView = entry.isIntersecting; }); sync(); }, { threshold }).observe(target);
68
- }
69
- }
64
+ if (watchReducedMotion) reducedQuery.addEventListener('change', sync, { signal });
65
+ const watchesPage = watchReducedMotion || !reducedAtStart;
66
+ if (watchesPage) document.addEventListener('visibilitychange', sync, { signal });
67
+ const observer = watchesPage && 'IntersectionObserver' in window
68
+ ? new IntersectionObserver((entries) => { entries.forEach((entry) => { inView = entry.isIntersecting; }); sync(); }, { threshold })
69
+ : undefined;
70
+ observer?.observe(target);
71
+ signal?.addEventListener('abort', () => { observer?.disconnect(); sync(); }, { once: true });
70
72
  sync();
71
73
  return { getState, sync };
72
74
  }