[FEAT] Bug fixes

This commit is contained in:
2026-01-07 00:53:23 +01:00
parent 77ae4bb429
commit ad28f6a607
3 changed files with 59 additions and 24 deletions

View File

@@ -615,27 +615,27 @@
flipX: false,
flipY: false,
};
const insertIndex = frameIndex + fileIdx;
if (insertIndex < layer.sprites.length) {
layer.sprites = [...layer.sprites.slice(0, insertIndex), sprite, ...layer.sprites.slice(insertIndex + 1)];
} else {
while (layer.sprites.length < insertIndex) {
layer.sprites.push({
id: crypto.randomUUID(),
file: new File([], 'empty'),
img: new Image(),
url: '',
width: 0,
height: 0,
x: 0,
y: 0,
rotation: 0,
flipX: false,
flipY: false,
});
}
layer.sprites = [...layer.sprites, sprite];
const targetIndex = frameIndex + fileIdx;
// Extend the array with empty slots if needed
while (layer.sprites.length <= targetIndex) {
layer.sprites.push({
id: crypto.randomUUID(),
file: new File([], 'empty'),
img: new Image(),
url: '',
width: 0,
height: 0,
x: 0,
y: 0,
rotation: 0,
flipX: false,
flipY: false,
});
}
// Now replace at target index (either existing sprite or empty placeholder)
layer.sprites = [...layer.sprites.slice(0, targetIndex), sprite, ...layer.sprites.slice(targetIndex + 1)];
};
img.src = url;
};