summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/map/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles/map/ui.js')
-rw-r--r--assets/javascripts/rectangles/map/ui.js35
1 files changed, 29 insertions, 6 deletions
diff --git a/assets/javascripts/rectangles/map/ui.js b/assets/javascripts/rectangles/map/ui.js
index f612fe2..ef96217 100644
--- a/assets/javascripts/rectangles/map/ui.js
+++ b/assets/javascripts/rectangles/map/ui.js
@@ -12,13 +12,12 @@ map.ui = new function(){
move: move,
drag: drag,
up: up,
+ rightclick: rightclick,
})
base.wheel = new wheel({
el: base.el,
- update: function(e, val, delta){
- // do something with val
- },
+ update: mousewheel,
})
//
@@ -27,6 +26,14 @@ map.ui = new function(){
cursor.x.div(map.zoom).add( map.center.a + map.bounds.a/2 )
cursor.y.div(map.zoom).add( -map.center.b - map.bounds.b/2 )
+ if (e.ctrlKey) {
+ map.center.a = cursor.x.b = cursor.x.a + map.bounds.a/2
+ map.center.b = cursor.y.b = cursor.y.a
+ base.mouse.down = false
+ e.preventDefault()
+ return
+ }
+
var intersects = clipper.rooms.filter(function(r){
return r.focused = r.rect.contains(cursor.x.a, cursor.y.a)
})
@@ -65,8 +72,8 @@ map.ui = new function(){
if (base.creating) {
if (cursor.height() != 0 && cursor.width() != 0) {
- cursor.x.abs()
- cursor.y.abs()
+ cursor.x.abs().quantize(1)
+ cursor.y.abs().quantize(1)
clipper.add_room( cursor )
}
}
@@ -77,4 +84,20 @@ map.ui = new function(){
base.creating = base.dragging = false
}
-} \ No newline at end of file
+
+ function mousewheel (e, val, delta){
+ var cursor = base.mouse.cursor
+
+ var intersects = clipper.rooms.filter(function(r){
+ return r.focused = r.rect.contains(cursor.x.a, cursor.y.a)
+ })
+
+ if (intersects.length) {
+ intersects[0].height = clamp( ~~(intersects[0].height - delta), 200, 800 )
+ clipper.update()
+ }
+ }
+
+ function rightclick (e){
+ }
+}