diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-06-11 17:24:16 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-06-11 17:24:16 -0400 |
| commit | 507ee48290b4d1d868de6e8c2518318be90eba2b (patch) | |
| tree | dec56cd3643d8178f0ffb964381a8c73273491b0 /public/assets/javascripts/rectangles/engine/map/ui.js | |
| parent | 50ba987880d90f40a5bf4d7e9e125b453723882b (diff) | |
handle map resizing
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/map/ui.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/map/ui.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/ui.js b/public/assets/javascripts/rectangles/engine/map/ui.js index 97baf88..7890c9b 100644 --- a/public/assets/javascripts/rectangles/engine/map/ui.js +++ b/public/assets/javascripts/rectangles/engine/map/ui.js @@ -22,8 +22,8 @@ var MapUI = function(map){ // function down (e, cursor){ - cursor.x.div(w).add(0.5).mul(map.bounds.a / map.zoom).add(map.center.a) - cursor.y.div(h).sub(0.5).mul(map.bounds.b / map.zoom).sub(map.center.b) + cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a) + cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b) if (e.ctrlKey || e.which === 3) { cursor.quantize(1/map.zoom) @@ -57,13 +57,13 @@ var MapUI = function(map){ } function move (e, cursor) { - cursor.x.div(w).add(0.5).mul(map.bounds.a / map.zoom).add(map.center.a) - cursor.y.div(h).sub(0.5).mul(map.bounds.b / map.zoom).sub(map.center.b) + cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a) + cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b) } function drag (e, cursor) { - cursor.x.b = ((cursor.x.b/w)+0.5) * map.bounds.a / map.zoom + map.center.a - cursor.y.b = ((cursor.y.b/h)-0.5) * map.bounds.b / map.zoom - map.center.b + cursor.x.b = ((cursor.x.b/map.dimensions.a)+0.5) * map.dimensions.a / map.zoom + map.center.a + cursor.y.b = ((cursor.y.b/map.dimensions.b)-0.5) * map.dimensions.b / map.zoom - map.center.b if (base.resizing) { var x_length = base.dragging.rect.x.length(), @@ -89,8 +89,8 @@ var MapUI = function(map){ } function up (e, cursor, new_cursor) { - new_cursor.x.div(w).add(0.5).mul(map.bounds.a / map.zoom).add(map.center.a) - new_cursor.y.div(h).sub(0.5).mul(map.bounds.b / map.zoom).sub(map.center.b) + new_cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a) + new_cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b) if (base.creating) { if (cursor.height() > side_min && cursor.width() > side_min) { |
