@tvuikit/scroll-pixi 0.2.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.
@@ -0,0 +1,43 @@
1
+ import type { Scroller, PixiContainerLike, ScrollAxis } from "@tvuikit/scroll";
2
+ export type PixiScrollerOptions = {
3
+ /** The Pixi container whose position will be driven by the scroller. */
4
+ container: PixiContainerLike;
5
+ /** The core scroller instance. */
6
+ scroller: Scroller;
7
+ /** Scroll direction. Default: "horizontal" */
8
+ axis?: ScrollAxis;
9
+ /**
10
+ * Optional callback to invalidate navigation registry bounds when
11
+ * the scroll position changes. Pass `pixiRegistry.invalidateAll`.
12
+ */
13
+ navigationInvalidate?: () => void;
14
+ };
15
+ export type PixiScroller = {
16
+ /**
17
+ * Call from your Pixi ticker. Applies the scroller's current offset
18
+ * to the container position and optionally invalidates navigation bounds.
19
+ */
20
+ tick(): void;
21
+ /** Stop tracking and release references. */
22
+ dispose(): void;
23
+ };
24
+ /**
25
+ * Create a Pixi scroll adapter that applies scroll offset to a container.
26
+ *
27
+ * This is a thin wrapper — GSAP animation happens inside the core scroller.
28
+ * The Pixi wrapper simply reads `scrollOffset` each tick and sets the
29
+ * container position. No closures in the tick path.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const pixiScroller = createPixiScroller({
34
+ * container: tilesContainer,
35
+ * scroller,
36
+ * axis: "horizontal",
37
+ * navigationInvalidate: pixiRegistry.invalidateAll.bind(pixiRegistry),
38
+ * });
39
+ * app.ticker.add(() => pixiScroller.tick());
40
+ * ```
41
+ */
42
+ export declare function createPixiScroller(options: PixiScrollerOptions): PixiScroller;
43
+ //# sourceMappingURL=createPixiScroller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPixiScroller.d.ts","sourceRoot":"","sources":["../src/createPixiScroller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE/E,MAAM,MAAM,mBAAmB,GAAG;IAChC,wEAAwE;IACxE,SAAS,EAAE,iBAAiB,CAAC;IAC7B,kCAAkC;IAClC,QAAQ,EAAE,QAAQ,CAAC;IACnB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,IAAI,IAAI,IAAI,CAAC;IACb,4CAA4C;IAC5C,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA0B7E"}
@@ -0,0 +1,2 @@
1
+ export { createPixiScroller, type PixiScrollerOptions, type PixiScroller, } from "./createPixiScroller.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ function a(t) {
2
+ const { container: i, scroller: n, navigationInvalidate: r } = t, s = (t.axis ?? "horizontal") === "horizontal";
3
+ let o = NaN, l = !1;
4
+ return {
5
+ tick() {
6
+ if (l) return;
7
+ const e = n.scrollOffset;
8
+ e !== o && (o = e, s ? i.x = -e : i.y = -e, r && r());
9
+ },
10
+ dispose() {
11
+ l = !0;
12
+ }
13
+ };
14
+ }
15
+ export {
16
+ a as createPixiScroller
17
+ };
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/createPixiScroller.ts"],"sourcesContent":["import type { Scroller, PixiContainerLike, ScrollAxis } from \"@tvuikit/scroll\";\n\nexport type PixiScrollerOptions = {\n /** The Pixi container whose position will be driven by the scroller. */\n container: PixiContainerLike;\n /** The core scroller instance. */\n scroller: Scroller;\n /** Scroll direction. Default: \"horizontal\" */\n axis?: ScrollAxis;\n /**\n * Optional callback to invalidate navigation registry bounds when\n * the scroll position changes. Pass `pixiRegistry.invalidateAll`.\n */\n navigationInvalidate?: () => void;\n};\n\nexport type PixiScroller = {\n /**\n * Call from your Pixi ticker. Applies the scroller's current offset\n * to the container position and optionally invalidates navigation bounds.\n */\n tick(): void;\n /** Stop tracking and release references. */\n dispose(): void;\n};\n\n/**\n * Create a Pixi scroll adapter that applies scroll offset to a container.\n *\n * This is a thin wrapper — GSAP animation happens inside the core scroller.\n * The Pixi wrapper simply reads `scrollOffset` each tick and sets the\n * container position. No closures in the tick path.\n *\n * @example\n * ```ts\n * const pixiScroller = createPixiScroller({\n * container: tilesContainer,\n * scroller,\n * axis: \"horizontal\",\n * navigationInvalidate: pixiRegistry.invalidateAll.bind(pixiRegistry),\n * });\n * app.ticker.add(() => pixiScroller.tick());\n * ```\n */\nexport function createPixiScroller(options: PixiScrollerOptions): PixiScroller {\n const { container, scroller, navigationInvalidate } = options;\n const horizontal = (options.axis ?? \"horizontal\") === \"horizontal\";\n\n let lastAppliedOffset = NaN;\n let disposed = false;\n\n return {\n tick(): void {\n if (disposed) return;\n const offset = scroller.scrollOffset;\n if (offset === lastAppliedOffset) return;\n lastAppliedOffset = offset;\n if (horizontal) {\n container.x = -offset;\n } else {\n container.y = -offset;\n }\n if (navigationInvalidate) {\n navigationInvalidate();\n }\n },\n dispose(): void {\n disposed = true;\n },\n };\n}\n"],"names":["createPixiScroller","options","container","scroller","navigationInvalidate","horizontal","lastAppliedOffset","disposed","offset"],"mappings":"AA4CO,SAASA,EAAmBC,GAA4C;AAC7E,QAAM,EAAE,WAAAC,GAAW,UAAAC,GAAU,sBAAAC,EAAA,IAAyBH,GAChDI,KAAcJ,EAAQ,QAAQ,kBAAkB;AAEtD,MAAIK,IAAoB,KACpBC,IAAW;AAEf,SAAO;AAAA,IACL,OAAa;AACX,UAAIA,EAAU;AACd,YAAMC,IAASL,EAAS;AACxB,MAAIK,MAAWF,MACfA,IAAoBE,GAChBH,IACFH,EAAU,IAAI,CAACM,IAEfN,EAAU,IAAI,CAACM,GAEbJ,KACFA,EAAA;AAAA,IAEJ;AAAA,IACA,UAAgB;AACd,MAAAG,IAAW;AAAA,IACb;AAAA,EAAA;AAEJ;"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@tvuikit/scroll-pixi",
3
+ "version": "0.2.0",
4
+ "description": "PixiJS adapter for @tvuikit/scroll. Applies scroll offset to Pixi containers.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "license": "MIT",
8
+ "author": "TVKit Team",
9
+ "homepage": "https://tvkit.dev/",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/dobreadi/tvkit.git",
13
+ "directory": "packages/scroll-pixi"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/dobreadi/tvkit/issues"
17
+ },
18
+ "keywords": [
19
+ "tv",
20
+ "scroll",
21
+ "pixi",
22
+ "pixijs",
23
+ "webgl",
24
+ "tvkit"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js"
36
+ }
37
+ },
38
+ "main": "./dist/index.js",
39
+ "module": "./dist/index.js",
40
+ "types": "./dist/index.d.ts",
41
+ "peerDependencies": {
42
+ "@tvuikit/scroll": "^0.1.0"
43
+ },
44
+ "devDependencies": {
45
+ "@tvuikit/scroll": "file:../scroll"
46
+ },
47
+ "scripts": {
48
+ "build": "vite build && npm run build:types",
49
+ "build:types": "tsc -p tsconfig.types.json",
50
+ "typecheck": "tsc -p tsconfig.json --noEmit"
51
+ }
52
+ }