pixi-solid 0.0.9 → 0.0.10
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/dist/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/use-resize.d.ts +9 -0
- package/dist/use-resize.js +27 -0
- package/dist/use-resize.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { PixiCanvas } from "./pixi-canvas.js";
|
|
|
3
3
|
import { PIXI_EVENT_NAMES } from "./pixi-events.js";
|
|
4
4
|
import { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, MeshSimple, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite } from "./pixi-components.js";
|
|
5
5
|
import { PixiStage } from "./pixi-stage.js";
|
|
6
|
+
import { useResize } from "./use-resize.js";
|
|
6
7
|
import { useTick, useTicker } from "./use-ticker.js";
|
|
7
8
|
|
|
8
|
-
export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, MeshSimple, NineSliceSprite, PIXI_EVENT_NAMES, ParticleContainer, PerspectiveMesh, PixiApplication, PixiCanvas, PixiStage, RenderContainer, RenderLayer, Sprite, Text, TilingSprite, usePixiApp, useTick, useTicker };
|
|
9
|
+
export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, MeshSimple, NineSliceSprite, PIXI_EVENT_NAMES, ParticleContainer, PerspectiveMesh, PixiApplication, PixiCanvas, PixiStage, RenderContainer, RenderLayer, Sprite, Text, TilingSprite, usePixiApp, useResize, useTick, useTicker };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export type { PixiEventHandlerMap } from "./pixi-events";
|
|
|
7
7
|
export { PIXI_EVENT_NAMES } from "./pixi-events";
|
|
8
8
|
export type { PixiStageProps } from "./pixi-stage";
|
|
9
9
|
export { PixiStage } from "./pixi-stage";
|
|
10
|
+
export { useResize } from "./use-resize";
|
|
10
11
|
export { useTick, useTicker } from "./use-ticker";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Pixi from "pixi.js";
|
|
2
|
+
/**
|
|
3
|
+
* A SolidJS hook that runs a callback function whenever the PixiJS renderer is resized.
|
|
4
|
+
*
|
|
5
|
+
* @param resizeCallback A callback function that receives the updated screen dimensions as a `Pixi.Rectangle` object. This function will be called immediately upon hook initialization and then on every subsequent resize event.
|
|
6
|
+
*
|
|
7
|
+
* Because we listen for the renderer's "resize" event, this hook will work correctly whether the window is resized or just the DOM element the PixiCanvas is inside changes size.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useResize: (resizeCallback: (screen: Pixi.Rectangle) => void) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { usePixiApp } from "./pixi-application.js";
|
|
2
|
+
import { onCleanup } from "solid-js";
|
|
3
|
+
|
|
4
|
+
//#region src/use-resize.ts
|
|
5
|
+
/**
|
|
6
|
+
* A SolidJS hook that runs a callback function whenever the PixiJS renderer is resized.
|
|
7
|
+
*
|
|
8
|
+
* @param resizeCallback A callback function that receives the updated screen dimensions as a `Pixi.Rectangle` object. This function will be called immediately upon hook initialization and then on every subsequent resize event.
|
|
9
|
+
*
|
|
10
|
+
* Because we listen for the renderer's "resize" event, this hook will work correctly whether the window is resized or just the DOM element the PixiCanvas is inside changes size.
|
|
11
|
+
*/
|
|
12
|
+
const useResize = (resizeCallback) => {
|
|
13
|
+
const app = usePixiApp();
|
|
14
|
+
app.renderer.screen.fit;
|
|
15
|
+
const handleResize = () => {
|
|
16
|
+
resizeCallback(app.renderer.screen);
|
|
17
|
+
};
|
|
18
|
+
handleResize();
|
|
19
|
+
app.renderer.addListener("resize", handleResize);
|
|
20
|
+
onCleanup(() => {
|
|
21
|
+
app.renderer.removeListener("resize", handleResize);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { useResize };
|
|
27
|
+
//# sourceMappingURL=use-resize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resize.js","names":[],"sources":["../src/use-resize.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { onCleanup } from \"solid-js\";\nimport { usePixiApp } from \"./pixi-application\";\n\n/**\n * A SolidJS hook that runs a callback function whenever the PixiJS renderer is resized.\n *\n * @param resizeCallback A callback function that receives the updated screen dimensions as a `Pixi.Rectangle` object. This function will be called immediately upon hook initialization and then on every subsequent resize event.\n *\n * Because we listen for the renderer's \"resize\" event, this hook will work correctly whether the window is resized or just the DOM element the PixiCanvas is inside changes size.\n */\nexport const useResize = (resizeCallback: (screen: Pixi.Rectangle) => void): void => {\n const app = usePixiApp();\n\n app.renderer.screen.fit;\n\n const handleResize = () => {\n resizeCallback(app.renderer.screen);\n };\n\n // Call once to initialise\n handleResize();\n\n app.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n app.renderer.removeListener(\"resize\", handleResize);\n });\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,aAAa,mBAA2D;CACnF,MAAM,MAAM,YAAY;AAExB,KAAI,SAAS,OAAO;CAEpB,MAAM,qBAAqB;AACzB,iBAAe,IAAI,SAAS,OAAO;;AAIrC,eAAc;AAEd,KAAI,SAAS,YAAY,UAAU,aAAa;AAEhD,iBAAgB;AACd,MAAI,SAAS,eAAe,UAAU,aAAa;GACnD"}
|