[FEAT] Prevent canvas from resizing when hiding layers
This commit is contained in:
@@ -319,12 +319,14 @@
|
||||
const gridMetrics = computed(() => calculateMaxDimensions());
|
||||
|
||||
const totalCells = computed(() => {
|
||||
const maxLen = Math.max(1, ...props.layers.map(l => (l.visible ? l.sprites.length : 1)));
|
||||
// Use all layers regardless of visibility to keep canvas size stable
|
||||
const maxLen = Math.max(1, ...props.layers.map(l => l.sprites.length));
|
||||
return Math.max(1, Math.ceil(maxLen / props.columns)) * props.columns;
|
||||
});
|
||||
|
||||
const gridDimensions = computed(() => {
|
||||
const maxLen = Math.max(1, ...props.layers.map(l => (l.visible ? l.sprites.length : 1)));
|
||||
// Use all layers regardless of visibility to keep canvas size stable
|
||||
const maxLen = Math.max(1, ...props.layers.map(l => l.sprites.length));
|
||||
const rows = Math.max(1, Math.ceil(maxLen / props.columns));
|
||||
return {
|
||||
width: gridMetrics.value.maxWidth * props.columns,
|
||||
|
||||
@@ -428,7 +428,8 @@
|
||||
|
||||
// Computed cell dimensions
|
||||
const cellDimensions = computed(() => {
|
||||
const visibleLayers = getVisibleLayers();
|
||||
// Use ALL layers (regardless of visibility) to keep preview size stable
|
||||
const allLayers = props.layers;
|
||||
// If manual cell size is enabled, use manual values
|
||||
if (settingsStore.manualCellSizeEnabled) {
|
||||
return {
|
||||
@@ -438,9 +439,9 @@
|
||||
};
|
||||
}
|
||||
|
||||
// Otherwise, calculate from sprite dimensions
|
||||
const { maxWidth, maxHeight } = getMaxDimensionsAcrossLayers(visibleLayers);
|
||||
const allSprites = visibleLayers.flatMap(l => l.sprites);
|
||||
// Otherwise, calculate from sprite dimensions across ALL layers
|
||||
const { maxWidth, maxHeight } = getMaxDimensionsAcrossLayers(allLayers);
|
||||
const allSprites = allLayers.flatMap(l => l.sprites);
|
||||
const negativeSpacing = calculateNegativeSpacing(allSprites, settingsStore.negativeSpacingEnabled);
|
||||
return {
|
||||
cellWidth: maxWidth + negativeSpacing,
|
||||
|
||||
Reference in New Issue
Block a user