summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/util
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles/util')
-rw-r--r--assets/javascripts/rectangles/util/constants.js9
-rw-r--r--assets/javascripts/rectangles/util/mouse.js8
2 files changed, 16 insertions, 1 deletions
diff --git a/assets/javascripts/rectangles/util/constants.js b/assets/javascripts/rectangles/util/constants.js
index db4eebf..fae4f1b 100644
--- a/assets/javascripts/rectangles/util/constants.js
+++ b/assets/javascripts/rectangles/util/constants.js
@@ -1,11 +1,18 @@
var FRONT = 0x1, BACK = 0x2, LEFT = 0x4, RIGHT = 0x8, FLOOR = 0x10, CEILING = 0x20
FRONT_BACK = FRONT | BACK, LEFT_RIGHT = LEFT | RIGHT, FLOOR_CEILING = FLOOR | CEILING
+var TOP = CEILING, BOTTOM = FLOOR,
+ TOP_LEFT = TOP | LEFT,
+ TOP_RIGHT = TOP | RIGHT,
+ BOTTOM_LEFT = BOTTOM | LEFT,
+ BOTTOM_RIGHT = BOTTOM | RIGHT
+
var height_min = 200,
height_max = 2000,
side_min = 10,
side_max = 5000,
- resize_margin = 8
+ resize_margin = 8,
+ cursor_amp = 1.5
var painting_distance_from_wall = 8
diff --git a/assets/javascripts/rectangles/util/mouse.js b/assets/javascripts/rectangles/util/mouse.js
index 16ca101..3aa7cfc 100644
--- a/assets/javascripts/rectangles/util/mouse.js
+++ b/assets/javascripts/rectangles/util/mouse.js
@@ -49,6 +49,7 @@ function mouse (opt) {
opt.move && base.tube.on("move", opt.move)
opt.drag && base.tube.on("drag", opt.drag)
opt.enter && base.tube.on("enter", opt.enter)
+ opt.leave && base.tube.on("leave", opt.leave)
opt.up && base.tube.on("up", opt.up)
opt.rightclick && base.tube.on("rightclick", opt.rightclick)
@@ -77,9 +78,11 @@ function mouse (opt) {
base.bind_el = function(el){
el.addEventListener("mousedown", base.mousedown)
+ el.addEventListener("mousemove", base.mousemove)
}
base.unbind_el = function(el){
el.removeEventListener("mousedown", base.mousedown)
+ el.removeEventListener("mousemove", base.mousemove)
}
function positionFromMouse(e) {
@@ -135,6 +138,11 @@ function mouse (opt) {
if (opt.use_offset && ! offset) return
base.tube("enter", e, el, base.cursor)
}
+ base.mouseleave = function(e, el){
+ if (! base.down) return
+ if (opt.use_offset && ! offset) return
+ base.tube("leave", e, el, base.cursor)
+ }
base.mouseup = function(e){
var pos, new_cursor