[FEAT] Bug fixes
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user