From 0a4848b723d45e5991c9bb0c19d3dbd602527743 Mon Sep 17 00:00:00 2001 From: Igor Zinken Date: Mon, 31 Jan 2022 09:56:19 +0100 Subject: [PATCH] Fix side effect introduced in f7daed6 where cropping a layer would not invalidate the renderers coordinate cache --- src/components/application-menu/application-menu.vue | 5 ++++- src/store/modules/document-module.js | 8 ++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/application-menu/application-menu.vue b/src/components/application-menu/application-menu.vue index ddbbcef..500d500 100644 --- a/src/components/application-menu/application-menu.vue +++ b/src/components/application-menu/application-menu.vue @@ -574,7 +574,10 @@ export default { const { left, top, width, height } = getRectangleForSelection( selection ); const commit = async () => { await store.commit( "cropActiveDocumentContent", { left, top }); - store.commit( "setActiveDocumentSize", { width, height }); + store.commit( "setActiveDocumentSize", { + width : Math.min( currentSize.width, width ), + height : Math.min( currentSize.height, height ) + }); getCanvasInstance()?.interactionPane.setSelection( null, false ); }; commit(); diff --git a/src/store/modules/document-module.js b/src/store/modules/document-module.js index 16199b7..b97362d 100644 --- a/src/store/modules/document-module.js +++ b/src/store/modules/document-module.js @@ -179,13 +179,9 @@ export default { }, async cropActiveDocumentContent( state, { left, top }) { const document = state.documents[ state.activeIndex ]; - for ( let i = 0, l = document?.layers?.length; i < l; ++i ) { - const layer = document.layers[ i ]; - // by toggling visiblity we force the Sprite to recache its contents when visible again - const wasVisible = layer.visible; - layer.visible = false; + for ( const layer of document?.layers ) { await cropLayerContent( layer, left, top ); - layer.visible = wasVisible; + getSpriteForLayer( layer )?.syncPosition(); } }, saveSelection( state, { name, selection }) {