mattjennings / svelte-pixi

Create PixiJS apps with Svelte
https://svelte-pixi.com
MIT License
112 stars 15 forks source link

Automatic Resize #22

Closed llPekoll closed 2 years ago

llPekoll commented 2 years ago

Hi, I am trying to resize application on the fly, I've try to do it using <svelte:window bind:innerWidth={w} bind:innerHeight={h} /> even tryied onMount(aync()=>{window.innerWidth={w};}) then

But it seems that the Application component is initialized before that. also, try resizeTo according to the doc ``` onMount(async()=>{ html = window.HTMLElement }) ``` I didn't find the proper way to do it. Could you help me, please?
mattjennings commented 2 years ago

@llPekoll For now you can dynamically resize by binding to the Application instance and calling app.renderer.resize().

<script>
import { Application } from 'svelte-pixi'
let app
let width
let height

$: if (app && width && height) {
  app.renderer.resize(width, height)
}
</script>

<svelte:window bind:innerHeight={height} bind:innerWidth={width} />
<Application bind:instance={app}>
</Application>

I'll consider adding this as the behaviour for the width/height props, I think it makes sense to do that. Currently the Application component more-or-less just sends the props to new PIXI.Application and has no reactivity on them after that.