ensure ImageEditor always draws at the correct position (#7959)

* reset layers on dimension change

* add changeset

* resets only if layer has dimension missmatch

* fix formatting

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: pngwn <hello@pngwn.io>
This commit is contained in:
hrrbay 2024-04-15 23:47:09 +02:00 committed by GitHub
parent 6fafce0670
commit 2a5cb97824
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/imageeditor": patch
"gradio": patch
---
fix:ensure `ImageEditor` always draws at the correct position

View File

@ -25,6 +25,19 @@
}
});
async function validate_layers(): Promise<void> {
let invalid = layers.some(
(layer) =>
layer.composite.texture.width != $dimensions[0] ||
layer.composite.texture.height != $dimensions[1]
);
if (invalid) {
LayerManager.reset();
new_layer();
}
}
$: $dimensions, validate_layers();
async function new_layer(): Promise<void> {
if (!$pixi) return;