diff options
Diffstat (limited to 'js/ui')
| -rw-r--r-- | js/ui/controls.js | 5 | ||||
| -rw-r--r-- | js/ui/selection.js | 15 |
2 files changed, 15 insertions, 5 deletions
diff --git a/js/ui/controls.js b/js/ui/controls.js index 4a576e5..0665747 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -106,14 +106,17 @@ var controls = (function(){ controls.grid = new BlurredCheckbox (grid_el) controls.grid.use = function(){ document.body.classList.toggle('grid') + if (!selection.hidden) selection.reposition() this.update( document.body.classList.contains("grid") ) } controls.grid.show = function(){ document.body.classList.add('grid') + if (!selection.hidden) selection.reposition() this.update( true ) } controls.grid.hide = function(){ document.body.classList.remove('grid') + if (!selection.hidden) selection.reposition() this.update( false ) } @@ -258,4 +261,4 @@ var controls = (function(){ } return controls -})()
\ No newline at end of file +})() diff --git a/js/ui/selection.js b/js/ui/selection.js index ed67023..abd7da2 100644 --- a/js/ui/selection.js +++ b/js/ui/selection.js @@ -48,14 +48,20 @@ var selection = (function(){ var contains_y = a[1] <= point[1] && point[1] <= b[1] return (contains_x && contains_y) } - function reposition (a,b) { - var cell = canvas.aa[top(a,b)][left(a,b)].span + function reposition (aa, bb) { + aa = aa || a + bb = bb || b + var cell = canvas.aa[top(aa, bb)][left(aa, bb)].span var cell_left = cell.offsetLeft var cell_top = cell.offsetTop var cell_width = 9 var cell_height = 16 - var w = width(a,b) - var h = height(a,b) + if (!document.body.classList.contains("grid")){ + cell_width -= 1 + cell_height -= 1 + } + var w = width(aa, bb) + var h = height(aa, bb) selector_el.style.top = (cell_top-1) + "px" selector_el.style.left = (cell_left-2) + "px" selector_el.style.width = (cell_width*w+1) + "px" @@ -140,6 +146,7 @@ var selection = (function(){ } var selection = {} + selection.reposition = reposition selection.down = down selection.move = move selection.up = up |
