Mission Control Dashboard - Initial implementation

This commit is contained in:
Daniel Arroyo
2026-03-27 18:36:05 +00:00
parent 257cea2c7d
commit a8fb4d4555
12516 changed files with 2307128 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
import { resolveElements } from 'motion-dom';
const thresholds = {
some: 0,
all: 1,
};
function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "some" } = {}) {
const elements = resolveElements(elementOrSelector);
const activeIntersections = new WeakMap();
const onIntersectionChange = (entries) => {
entries.forEach((entry) => {
const onEnd = activeIntersections.get(entry.target);
/**
* If there's no change to the intersection, we don't need to
* do anything here.
*/
if (entry.isIntersecting === Boolean(onEnd))
return;
if (entry.isIntersecting) {
const newOnEnd = onStart(entry.target, entry);
if (typeof newOnEnd === "function") {
activeIntersections.set(entry.target, newOnEnd);
}
else {
observer.unobserve(entry.target);
}
}
else if (typeof onEnd === "function") {
onEnd(entry);
activeIntersections.delete(entry.target);
}
});
};
const observer = new IntersectionObserver(onIntersectionChange, {
root,
rootMargin,
threshold: typeof amount === "number" ? amount : thresholds[amount],
});
elements.forEach((element) => observer.observe(element));
return () => observer.disconnect();
}
export { inView };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../src/render/dom/viewport/index.ts"],"sourcesContent":["import { ElementOrSelector, resolveElements } from \"motion-dom\"\n\nexport type ViewChangeHandler = (entry: IntersectionObserverEntry) => void\n\ntype MarginValue = `${number}${\"px\" | \"%\"}`\ntype MarginType =\n | MarginValue\n | `${MarginValue} ${MarginValue}`\n | `${MarginValue} ${MarginValue} ${MarginValue}`\n | `${MarginValue} ${MarginValue} ${MarginValue} ${MarginValue}`\n\nexport interface InViewOptions {\n root?: Element | Document\n margin?: MarginType\n amount?: \"some\" | \"all\" | number\n}\n\nconst thresholds = {\n some: 0,\n all: 1,\n}\n\nexport function inView(\n elementOrSelector: ElementOrSelector,\n onStart: (\n element: Element,\n entry: IntersectionObserverEntry\n ) => void | ViewChangeHandler,\n { root, margin: rootMargin, amount = \"some\" }: InViewOptions = {}\n): VoidFunction {\n const elements = resolveElements(elementOrSelector)\n\n const activeIntersections = new WeakMap<Element, ViewChangeHandler>()\n\n const onIntersectionChange: IntersectionObserverCallback = (entries) => {\n entries.forEach((entry) => {\n const onEnd = activeIntersections.get(entry.target)\n\n /**\n * If there's no change to the intersection, we don't need to\n * do anything here.\n */\n if (entry.isIntersecting === Boolean(onEnd)) return\n\n if (entry.isIntersecting) {\n const newOnEnd = onStart(entry.target, entry)\n if (typeof newOnEnd === \"function\") {\n activeIntersections.set(entry.target, newOnEnd)\n } else {\n observer.unobserve(entry.target)\n }\n } else if (typeof onEnd === \"function\") {\n onEnd(entry)\n activeIntersections.delete(entry.target)\n }\n })\n }\n\n const observer = new IntersectionObserver(onIntersectionChange, {\n root,\n rootMargin,\n threshold: typeof amount === \"number\" ? amount : thresholds[amount],\n })\n\n elements.forEach((element) => observer.observe(element))\n\n return () => observer.disconnect()\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,UAAU,GAAG;AACf,IAAA,IAAI,EAAE,CAAC;AACP,IAAA,GAAG,EAAE,CAAC;CACT;SAEe,MAAM,CAClB,iBAAoC,EACpC,OAG6B,EAC7B,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,KAAoB,EAAE,EAAA;AAEjE,IAAA,MAAM,QAAQ,GAAG,eAAe,CAAC,iBAAiB,CAAC;AAEnD,IAAA,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAA8B;AAErE,IAAA,MAAM,oBAAoB,GAAiC,CAAC,OAAO,KAAI;AACnE,QAAA,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;YACtB,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;AAEnD;;;AAGG;AACH,YAAA,IAAI,KAAK,CAAC,cAAc,KAAK,OAAO,CAAC,KAAK,CAAC;gBAAE;AAE7C,Y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