Skip to content

Commit

Permalink
fixed issue, where opening big image + json would end with wrong prev…
Browse files Browse the repository at this point in the history
…iew in main canvas
  • Loading branch information
viliusle committed Oct 24, 2021
1 parent 076ceae commit e32e7d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/js/core/base-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ class Base_layers_class {
}

/**
* returns global position, for example if canvas is zoomed, it will convert relative mouse position to absolute at 100% zoom.
* returns global position, for example if canvas is zoomed, it will convert relative mouse position to absolute
* at 100% zoom.
*
* @param {int} x
* @param {int} y
Expand Down
8 changes: 6 additions & 2 deletions src/js/core/gui/gui-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var template = `
<div class="canvas_preview_details">
<div class="details">
<button title="Zoom out" class="layer_add trn" id="zoom_less"">-</button>
<button title="Reset zoom level" class="layer_add trn" id="zoom_100"">100%</button>
<button title="Reset zoom level" class="layer_add trn" id="zoom_100">100%</button>
<button title="Zoom in" class="layer_add trn" id="zoom_more"">+</button>
<button class="layer_add trn" id="zoom_fit">Fit</button>
</div>
Expand Down Expand Up @@ -209,7 +209,7 @@ class GUI_preview_class {
this.canvas_preview.stroke();
}

zoom(recalc) {
async zoom(recalc) {
if (recalc != undefined) {
//zoom-in or zoom-out
if (recalc == 1 || recalc == -1) {
Expand Down Expand Up @@ -275,6 +275,10 @@ class GUI_preview_class {

config.need_render = true;
this.GUI.prepare_canvas();

//sleep after last image import, it maybe not be finished yet
await new Promise(r => setTimeout(r, 10));

return true;
}

Expand Down
5 changes: 4 additions & 1 deletion src/js/modules/file/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class File_open_class {
}

/**
* includes provided resource (iamge or json)
* includes provided resource (image or json)
*
* @param string resource_url
*/
Expand Down Expand Up @@ -591,6 +591,9 @@ class File_open_class {

const actions = [];

//reset zoom
await this.Base_gui.GUI_preview.zoom(100); //reset zoom

//set attributes
actions.push(
new app.Actions.Refresh_action_attributes_action('undo'),
Expand Down

0 comments on commit e32e7d6

Please sign in to comment.