diff --git a/src/components/document-canvas/document-canvas.vue b/src/components/document-canvas/document-canvas.vue
index b73bcb5..8e31436 100644
--- a/src/components/document-canvas/document-canvas.vue
+++ b/src/components/document-canvas/document-canvas.vue
@@ -109,9 +109,9 @@ export default {
"activeTool",
"activeToolOptions",
"antiAlias",
+ "canvasDimensions",
"snapAlign",
"zoomOptions",
- "zCanvasBaseDimensions",
]),
documentTitle() {
const { name } = this.activeDocument;
@@ -151,6 +151,7 @@ export default {
renderState.reset();
layerPool.clear();
this.calcIdealDimensions();
+ this.setToolOptionValue({ tool: ToolTypes.ZOOM, option: "level", value: 1 }); // reset zoom
this.$nextTick( async () => {
// previously active tool needs to update to new document ref
const tool = this.activeTool;
@@ -262,10 +263,11 @@ export default {
},
methods: {
...mapMutations([
- "setZCanvasBaseDimensions",
+ "setCanvasDimensions",
"setActiveTool",
"setPanMode",
"setSelectMode",
+ "setToolOptionValue",
]),
...mapActions([
"requestDocumentClose",
@@ -309,20 +311,30 @@ export default {
if ( calculateBestFit ) {
const { width, height } = this.activeDocument;
const scaledSize = scaleToRatio( width, height, containerSize.width, containerSize.height );
- this.setZCanvasBaseDimensions( scaledSize );
- xScale = scaledSize.width / this.activeDocument.width;
- yScale = scaledSize.height / this.activeDocument.height;
const maxScaling = calculateMaxScaling( scaledSize.width, scaledSize.height, width, containerSize.width );
+
maxInScale = maxScaling.in;
maxOutScale = maxScaling.out;
+
+ this.setCanvasDimensions({
+ ...scaledSize,
+ visibleWidth : containerSize.width,
+ visibleHeight : containerSize.height,
+ maxInScale,
+ maxOutScale
+ });
+
+ xScale = scaledSize.width / this.activeDocument.width;
+ yScale = scaledSize.height / this.activeDocument.height;
+
this.viewportWidth = containerSize.width;
this.viewportHeight = containerSize.height;
zCanvas.setViewport( this.viewportWidth, this.viewportHeight );
}
this.scaleWrapper();
// replace below with updated zCanvas lib to not multiply by zoom
- this.cvsWidth = this.zCanvasBaseDimensions.width * zoom;
- this.cvsHeight = this.zCanvasBaseDimensions.height * zoom;
+ this.cvsWidth = this.canvasDimensions.width * zoom;
+ this.cvsHeight = this.canvasDimensions.height * zoom;
zCanvas.setDocumentScale( this.cvsWidth, this.cvsHeight, xScale, zoom, this.activeDocument );
this.centerCanvas = zCanvas.getWidth() < containerSize.width || zCanvas.getHeight() < containerSize.height ;
},
diff --git a/src/components/file-import/file-selector/file-selector.vue b/src/components/file-import/file-selector/file-selector.vue
index d1e8907..cc696fb 100644
--- a/src/components/file-import/file-selector/file-selector.vue
+++ b/src/components/file-import/file-selector/file-selector.vue
@@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
- * Igor Zinken 2020-2021 - https://www.igorski.nl
+ * Igor Zinken 2020-2022 - https://www.igorski.nl
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -22,15 +22,17 @@
*/
-
-
diff --git a/src/components/tool-options-panel/tool-options-zoom/messages.json b/src/components/tool-options-panel/tool-options-zoom/messages.json
index 5405518..5673f5c 100644
--- a/src/components/tool-options-panel/tool-options-zoom/messages.json
+++ b/src/components/tool-options-panel/tool-options-zoom/messages.json
@@ -2,6 +2,7 @@
"en-US": {
"zoomLevel": "Zoom level",
"bestFit": "Best fit",
+ "fitWindow": "Fit window",
"original": "Original"
}
}
diff --git a/src/components/tool-options-panel/tool-options-zoom/tool-options-zoom.vue b/src/components/tool-options-panel/tool-options-zoom/tool-options-zoom.vue
index 3eba014..dc54bf9 100644
--- a/src/components/tool-options-panel/tool-options-zoom/tool-options-zoom.vue
+++ b/src/components/tool-options-panel/tool-options-zoom/tool-options-zoom.vue
@@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
- * Igor Zinken 2020-2021 - https://www.igorski.nl
+ * Igor Zinken 2020-2022 - https://www.igorski.nl
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -38,6 +38,12 @@
class="button button--small"
@click="setBestFit()"
>
+