From 3931220adfa0ea8dca356169f626e18089fa463b Mon Sep 17 00:00:00 2001 From: cantbesure1 Date: Mon, 13 Nov 2017 17:28:06 -0800 Subject: [PATCH] small bugfixes --- sources/scripts/dotgrid.js | 24 +++++++++++++++++------- sources/scripts/guide.js | 18 ++++++++++-------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index 2492b64..e4f3699 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -145,12 +145,22 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca if(dotgrid.translation){ dotgrid.translation.to = pos; } - this.cursor.style.left = Math.floor(-(pos.x-this.grid_width)); - this.cursor.style.top = Math.floor(pos.y+this.grid_height); - this.cursor_coord.className = -pos.x > this.width/2 ? "fl left" : "fl" - this.cursor_coord.textContent = parseInt(-pos.x/this.grid_width)+","+parseInt(pos.y/this.grid_height); + if(pos.x>0) { + this.cursor.style.visibility = "hidden" + } else { + if(this.cursor.style.visibility == "hidden") { + this.cursor.style.transition = "initial" + } + this.cursor.style.visibility = "visible" + this.cursor.style.left = Math.floor(-(pos.x-this.grid_width)); + this.cursor.style.top = Math.floor(pos.y+this.grid_height); + this.cursor_coord.className = -pos.x > this.width/2 ? "fl left" : "fl" + this.cursor_coord.textContent = parseInt(-pos.x/this.grid_width)+","+parseInt(pos.y/this.grid_height); + window.setTimeout(() => dotgrid.cursor.style.transition = "all 50ms", 17 /*one frame*/) + } dotgrid.guide.update(); + } this.mouse_up = function(e) @@ -160,14 +170,14 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca if(e.altKey){ return; } - if(dotgrid.translation && !dotgrid.translation.to.is_equal(dotgrid.translation.from)){ + if(pos.x>0) { dotgrid.translation = null; return; } + + if(dotgrid.translation && !dotgrid.translation.to.is_equal(dotgrid.translation.from) ){ dotgrid.translate(dotgrid.translation); return; } dotgrid.translation = null; - - if(pos.x>0) return; if(from === null){ this.set_from(pos.scale(1/this.scale)); } else if(to === null){ this.set_to(pos.scale(1/this.scale)); } diff --git a/sources/scripts/guide.js b/sources/scripts/guide.js index e9afe33..1ea9ea0 100644 --- a/sources/scripts/guide.js +++ b/sources/scripts/guide.js @@ -90,13 +90,15 @@ function Guide() var from = dotgrid.translation.from; var to = dotgrid.translation.to; - ctx.beginPath(); - ctx.moveTo((from.x * -2)+20,(from.y * 2)+20); - ctx.lineTo((to.x * -2)+20,(to.y * 2)+20); - ctx.lineCap="round"; - ctx.lineWidth = 5; - ctx.strokeStyle = dotgrid.theme.active.f_high; - ctx.stroke(); - ctx.closePath(); + if(to.x<=0) { + ctx.beginPath(); + ctx.moveTo((from.x * -2)+20,(from.y * 2)+20); + ctx.lineTo((to.x * -2)+20,(to.y * 2)+20); + ctx.lineCap="round"; + ctx.lineWidth = 5; + ctx.strokeStyle = dotgrid.theme.active.f_high; + ctx.stroke(); + ctx.closePath(); + } } } \ No newline at end of file