@griddle/vue 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -39,6 +39,31 @@ const api = useGriddle({
39
39
  </template>
40
40
  ```
41
41
 
42
+ ## Animation configuration
43
+
44
+ Tile repositioning and lift animations share `config.animation` with the other
45
+ Griddle adapters. Repositioning defaults to a smooth 320 ms ease-out and rapid
46
+ repacks continue from each tile's current visual position.
47
+
48
+ ```ts
49
+ const api = useGriddle({
50
+ config: {
51
+ cols: 12, rows: 12, unitWidth: 75, unitHeight: 75,
52
+ animation: {
53
+ repositionDurationMs: 320,
54
+ repositionEasing: 'cubic-bezier(0.22, 1, 0.36, 1)',
55
+ liftDurationMs: 160,
56
+ liftEasing: 'cubic-bezier(0.22, 1, 0.36, 1)',
57
+ respectReducedMotion: true,
58
+ },
59
+ },
60
+ tiles,
61
+ });
62
+ ```
63
+
64
+ Use `animation.enabled: false` to disable all adapter animations. A duration of
65
+ `0` disables only that transition.
66
+
42
67
  ## Loop mode (infinite gallery)
43
68
 
44
69
  Enable `loop` in the config and the content repeats endlessly with drag-to-pan
@@ -1 +1 @@
1
- {"version":3,"file":"GriddleGrid.vue.d.ts","sourceRoot":"","sources":["../src/GriddleGrid.vue"],"names":[],"mappings":"AAwuBA,OAAO,KAAK,EAAE,WAAW,EAAU,IAAI,EAAE,MAAM,eAAe,CAAC;AAc/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,UAAU,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC;AAowBF,QAAA,IAAI,QAA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core';
2
+ /** Continue rapid repacks from the tile's current visual position. */
3
+ export declare function animateReposition(node: HTMLElement, deltaX: number, deltaY: number, config?: GridAnimationConfig): void;
4
+ export declare function liftTransition(config?: GridAnimationConfig): string;
5
+ //# sourceMappingURL=animation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../src/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAoBvB,sEAAsE;AACtE,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,mBAAmB,GAC3B,IAAI,CAwBN;AAED,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAMnE"}
@@ -0,0 +1,36 @@
1
+ import { resolveAnimationConfig as r } from "@griddle/core";
2
+ const o = /* @__PURE__ */ new WeakMap();
3
+ function u(t) {
4
+ return r(t).respectReducedMotion && typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
5
+ }
6
+ function p(t) {
7
+ if (typeof window > "u") return { x: 0, y: 0 };
8
+ const n = window.getComputedStyle(t).translate;
9
+ if (!n || n === "none") return { x: 0, y: 0 };
10
+ const [e = "0", i = "0"] = n.split(/\s+/);
11
+ return { x: Number.parseFloat(e) || 0, y: Number.parseFloat(i) || 0 };
12
+ }
13
+ function f(t, n, e, i) {
14
+ const s = o.get(t);
15
+ s !== void 0 && cancelAnimationFrame(s);
16
+ const a = r(i);
17
+ if (!a.enabled || a.repositionDurationMs === 0 || u(i)) {
18
+ t.style.transition = "none", t.style.translate = "0px 0px", o.delete(t);
19
+ return;
20
+ }
21
+ const l = p(t);
22
+ t.style.transition = "none", t.style.translate = `${n + l.x}px ${e + l.y}px`, t.offsetWidth;
23
+ const c = requestAnimationFrame(() => {
24
+ o.delete(t), t.style.transition = `translate ${a.repositionDurationMs}ms ${a.repositionEasing}`, t.style.translate = "0px 0px";
25
+ });
26
+ o.set(t, c);
27
+ }
28
+ function d(t) {
29
+ const n = r(t), e = !n.enabled || u(t) ? 0 : n.liftDurationMs;
30
+ return `filter ${e}ms ${n.liftEasing}, opacity ${e}ms ${n.liftEasing}`;
31
+ }
32
+ export {
33
+ f as animateReposition,
34
+ d as liftTransition
35
+ };
36
+ //# sourceMappingURL=animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.js","sources":["../src/animation.ts"],"sourcesContent":["import {\n resolveAnimationConfig,\n type GridAnimationConfig,\n} from '@griddle/core';\n\nconst pendingFrames = new WeakMap<HTMLElement, number>();\n\nfunction reducedMotionRequested(config: GridAnimationConfig | undefined): boolean {\n const animation = resolveAnimationConfig(config);\n return animation.respectReducedMotion &&\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\nfunction currentTranslation(node: HTMLElement): { x: number; y: number } {\n if (typeof window === 'undefined') return { x: 0, y: 0 };\n const translate = window.getComputedStyle(node).translate;\n if (!translate || translate === 'none') return { x: 0, y: 0 };\n const [x = '0', y = '0'] = translate.split(/\\s+/);\n return { x: Number.parseFloat(x) || 0, y: Number.parseFloat(y) || 0 };\n}\n\n/** Continue rapid repacks from the tile's current visual position. */\nexport function animateReposition(\n node: HTMLElement,\n deltaX: number,\n deltaY: number,\n config?: GridAnimationConfig,\n): void {\n const pending = pendingFrames.get(node);\n if (pending !== undefined) cancelAnimationFrame(pending);\n\n const animation = resolveAnimationConfig(config);\n if (!animation.enabled || animation.repositionDurationMs === 0 || reducedMotionRequested(config)) {\n node.style.transition = 'none';\n node.style.translate = '0px 0px';\n pendingFrames.delete(node);\n return;\n }\n\n const current = currentTranslation(node);\n node.style.transition = 'none';\n node.style.translate = `${deltaX + current.x}px ${deltaY + current.y}px`;\n void node.offsetWidth;\n\n const frame = requestAnimationFrame(() => {\n pendingFrames.delete(node);\n node.style.transition =\n `translate ${animation.repositionDurationMs}ms ${animation.repositionEasing}`;\n node.style.translate = '0px 0px';\n });\n pendingFrames.set(node, frame);\n}\n\nexport function liftTransition(config?: GridAnimationConfig): string {\n const animation = resolveAnimationConfig(config);\n const duration = !animation.enabled || reducedMotionRequested(config)\n ? 0\n : animation.liftDurationMs;\n return `filter ${duration}ms ${animation.liftEasing}, opacity ${duration}ms ${animation.liftEasing}`;\n}\n"],"names":["pendingFrames","reducedMotionRequested","config","resolveAnimationConfig","currentTranslation","node","translate","x","y","animateReposition","deltaX","deltaY","pending","animation","current","frame","liftTransition","duration"],"mappings":";AAKA,MAAMA,wBAAoB,QAAA;AAE1B,SAASC,EAAuBC,GAAkD;AAEhF,SADkBC,EAAuBD,CAAM,EAC9B,wBACf,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,cAC7B,OAAO,WAAW,kCAAkC,EAAE;AAC1D;AAEA,SAASE,EAAmBC,GAA6C;AACvE,MAAI,OAAO,SAAW,IAAa,QAAO,EAAE,GAAG,GAAG,GAAG,EAAA;AACrD,QAAMC,IAAY,OAAO,iBAAiBD,CAAI,EAAE;AAChD,MAAI,CAACC,KAAaA,MAAc,eAAe,EAAE,GAAG,GAAG,GAAG,EAAA;AAC1D,QAAM,CAACC,IAAI,KAAKC,IAAI,GAAG,IAAIF,EAAU,MAAM,KAAK;AAChD,SAAO,EAAE,GAAG,OAAO,WAAWC,CAAC,KAAK,GAAG,GAAG,OAAO,WAAWC,CAAC,KAAK,EAAA;AACpE;AAGO,SAASC,EACdJ,GACAK,GACAC,GACAT,GACM;AACN,QAAMU,IAAUZ,EAAc,IAAIK,CAAI;AACtC,EAAIO,MAAY,UAAW,qBAAqBA,CAAO;AAEvD,QAAMC,IAAYV,EAAuBD,CAAM;AAC/C,MAAI,CAACW,EAAU,WAAWA,EAAU,yBAAyB,KAAKZ,EAAuBC,CAAM,GAAG;AAChG,IAAAG,EAAK,MAAM,aAAa,Q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