Hide preview if you would be zooming out

main
Isaiah Odhner 2019-10-26 13:35:14 -04:00
parent 47bb0b075b
commit 3e0ca7a687
2 changed files with 16 additions and 9 deletions

View File

@ -442,7 +442,7 @@ $G.on("cut copy paste", function(e){
reset_file();
reset_colors();
reset_canvas(); // (with newly reset colors)
reset_magnification();
set_magnification(1);
storage.get({
width: default_canvas_width,

View File

@ -325,10 +325,16 @@ tools = [{
deselect: true,
passive: true,
getProspectiveMagnification: ()=> (
magnification === 1 ? return_to_magnification : 1
),
drawPreviewAboveGrid: function(ctx, x, y, scaled_by_amount, grid_visible) {
if(!pointer_active && !pointer_over_canvas){return;}
if(pointer_active) { return; } // TODO: fix flash / whatever
// TODO: hide if would be zooming out
if(pointer_active) { return; }
var prospective_magnification = this.getProspectiveMagnification();
if(prospective_magnification < magnification) { return; } // hide if would be zooming out
var hairline_width = 1/scaled_by_amount;
@ -357,12 +363,13 @@ tools = [{
}
},
pointerdown: function(ctx, x, y){
if(magnification !== 1){
reset_magnification();
}else{
var prev_magnification = magnification;
var prospective_magnification = this.getProspectiveMagnification();
// TODO: dedupe update_helper_layer
set_magnification(return_to_magnification);
set_magnification(prospective_magnification);
if (prospective_magnification > prev_magnification) {
var scroll_left = $canvas_area.scrollLeft();
var scroll_top = $canvas_area.scrollTop();
// TODO: size rectangle based on viewport, and get position actually right