diff --git a/src/composables/useLayers.ts b/src/composables/useLayers.ts index d8b78eb..0078025 100644 --- a/src/composables/useLayers.ts +++ b/src/composables/useLayers.ts @@ -153,7 +153,15 @@ export const useLayers = () => { URL.revokeObjectURL(s.url); } catch {} } - l.sprites.splice(i, 1); + + if (layers.value.length > 1) { + // If there are multiple layers, we want to maintain frame alignment + // so we replace the sprite with an empty one instead of shifting + l.sprites[i] = createEmptySprite(); + } else { + // If there's only one layer, we can safely remove the frame + l.sprites.splice(i, 1); + } }; const removeSprites = (ids: string[]) => { @@ -175,7 +183,12 @@ export const useLayers = () => { URL.revokeObjectURL(s.url); } catch {} } - l.sprites.splice(i, 1); + + if (layers.value.length > 1) { + l.sprites[i] = createEmptySprite(); + } else { + l.sprites.splice(i, 1); + } }); };