Skip to content

Commit e8c6e55

Browse files
committed
fix: allow width and height props to accept both Number and String types in Application component
1 parent 91bfd6e commit e8c6e55

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

packages/core/src/components/application/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable ts/ban-ts-comment */
21
/* eslint-disable ts/no-redeclare */
32
import type { ColorSource, Container, GpuPowerPreference } from 'pixi.js'
43
import type { App, PropType } from 'vue-demi'
@@ -40,8 +39,8 @@ export const Application = defineComponent({
4039
resizeTo: Object as PropType<HTMLElement | Window | undefined>,
4140
roundPixels: { type: Boolean, default: undefined },
4241
useBackBuffer: { type: Boolean, default: undefined },
43-
width: { type: Number, default: undefined },
44-
height: { type: Number, default: undefined },
42+
width: { type: [Number, String], default: undefined },
43+
height: { type: [Number, String], default: undefined },
4544
resolution: { type: Number, default: 1 },
4645

4746
// @TODO: Add webgl/webgpu
@@ -55,7 +54,13 @@ export const Application = defineComponent({
5554

5655
async function mount() {
5756
const inst = new PixiApplication()
58-
await inst.init({ canvas: canvas.value, ...props, preference: 'webgl' })
57+
await inst.init({
58+
canvas: canvas.value,
59+
...props,
60+
preference: 'webgl',
61+
width: props.width ? Number(props.width) : undefined,
62+
height: props.height ? Number(props.height) : undefined,
63+
})
5964

6065
pixiApp.value = markRaw(inst)
6166

@@ -77,7 +82,6 @@ export const Application = defineComponent({
7782
app = undefined
7883

7984
pixiApp.value?.destroy(
80-
// @ts-ignore
8185
{ releaseGlobalResources: true, removeView: true },
8286
{
8387
children: true,

packages/core/src/composables/useApplication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { appInjectKey } from './internal'
66
export function useApplication<T = Application>(): Ref<T> {
77
const app = ref(inject(appInjectKey, undefined))
88
const appComputed = computed({
9-
get: () => (app.value as any)?.app,
9+
get: () => (app.value as any)?.app || app.value,
1010
set: (value: any) => app.value = value,
1111
})
1212

0 commit comments

Comments
 (0)