@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.
- package/CHANGELOG.md +13 -0
- package/README.md +46 -0
- package/package.json +13 -6
- package/src/ContactCard.astro +107 -0
- package/src/contactCard/CardActions.astro +20 -0
- package/src/contactCard/CardBrand.astro +25 -0
- package/src/contactCard/CardContacts.astro +22 -0
- package/src/contactCard/CardContactsVariant.ts +5 -0
- package/src/contactCard/CardDialog.astro +16 -0
- package/src/contactCard/CardIcon.astro +12 -0
- package/src/contactCard/CardIconName.ts +6 -0
- package/src/contactCard/CardIdentity.astro +14 -0
- package/src/contactCard/CardLinkKind.ts +6 -0
- package/src/contactCard/CardPortrait.astro +14 -0
- package/src/contactCard/CardQr.astro +24 -0
- package/src/contactCard/CardSave.astro +43 -0
- package/src/contactCard/CardValues.astro +12 -0
- package/src/contactCard/ContactCardLayout.ts +7 -0
- package/src/contactCard/ContactPhotoType.ts +5 -0
- package/src/contactCard/InstallRoute.ts +6 -0
- package/src/contactCard/cardIcons.ts +11 -0
- package/src/contactCard/cardLinks.ts +43 -0
- package/src/contactCard/checks.ts +28 -0
- package/src/contactCard/chooseInstall.ts +21 -0
- package/src/contactCard/contactCard.css +69 -0
- package/src/contactCard/index.ts +16 -0
- package/src/contactCard/layouts.css +106 -0
- package/src/contactCard/manifest.ts +37 -0
- package/src/contactCard/motion/OpenMotion.ts +7 -0
- package/src/contactCard/motion/QrMotion.ts +7 -0
- package/src/contactCard/motion/SaveMotion.ts +7 -0
- package/src/contactCard/motion/TiltMotion.ts +7 -0
- package/src/contactCard/motion/beatTable.ts +144 -0
- package/src/contactCard/motion/beats.ts +43 -0
- package/src/contactCard/motion/cardMotion.ts +49 -0
- package/src/contactCard/motion/easings.ts +9 -0
- package/src/contactCard/motion/holdDuringOpen.ts +22 -0
- package/src/contactCard/motion/mountMotion.ts +26 -0
- package/src/contactCard/motion/mountOpenMark.ts +20 -0
- package/src/contactCard/motion/mountQrTurn.ts +86 -0
- package/src/contactCard/motion/mountSave.ts +26 -0
- package/src/contactCard/motion/mountTilt.ts +92 -0
- package/src/contactCard/motion/openCss.ts +18 -0
- package/src/contactCard/motion/parts.ts +25 -0
- package/src/contactCard/motion/playBeats.ts +21 -0
- package/src/contactCard/motion/sides.ts +33 -0
- package/src/contactCard/motion/tiltPose.ts +38 -0
- package/src/contactCard/motion.css +39 -0
- package/src/contactCard/mount.ts +76 -0
- package/src/contactCard/phone.ts +11 -0
- package/src/contactCard/qrSvg.ts +54 -0
- package/src/contactCard/types.ts +47 -0
- package/src/contactCard/vCard.ts +48 -0
- package/src/contactCard/vCardLines.ts +33 -0
- 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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
}
|