This commit is contained in:
James Campos 2011-08-23 02:33:08 -07:00
parent 1a4c0429a3
commit 16b3a8cbd9
2 changed files with 24 additions and 20 deletions

View File

@ -226,7 +226,7 @@
return ui.height = d.body.clientHeight - el.offsetHeight; return ui.height = d.body.clientHeight - el.offsetHeight;
}, },
drag: function(e) { drag: function(e) {
var bottom, el, left, right, top; var bottom, el, left, right, style, top;
el = ui.el; el = ui.el;
left = e.clientX - ui.dx; left = e.clientX - ui.dx;
if (left < 10) { if (left < 10) {
@ -242,10 +242,11 @@
top = null; top = null;
} }
bottom = top ? null : 0; bottom = top ? null : 0;
el.style.top = top; style = el.style;
el.style.right = right; style.top = top;
el.style.bottom = bottom; style.right = right;
return el.style.left = left; style.bottom = bottom;
return style.left = left;
}, },
dragend: function() { dragend: function() {
var el, id; var el, id;
@ -257,19 +258,20 @@
return d.removeEventListener('mouseup', ui.dragend, false); return d.removeEventListener('mouseup', ui.dragend, false);
}, },
hover: function(e) { hover: function(e) {
var clientHeight, clientWidth, clientX, clientY, el, height, top, _ref; var clientHeight, clientWidth, clientX, clientY, el, height, style, top, _ref;
clientX = e.clientX, clientY = e.clientY; clientX = e.clientX, clientY = e.clientY;
el = ui.el; el = ui.el;
style = el.style;
_ref = d.body, clientHeight = _ref.clientHeight, clientWidth = _ref.clientWidth; _ref = d.body, clientHeight = _ref.clientHeight, clientWidth = _ref.clientWidth;
height = el.offsetHeight; height = el.offsetHeight;
top = clientY - 120; top = clientY - 120;
el.style.top = clientHeight < height || top < 0 ? 0 : top + height > clientHeight ? clientHeight - height : top; style.top = clientHeight < height || top < 0 ? 0 : top + height > clientHeight ? clientHeight - height : top;
if (clientX < clientWidth - 400) { if (clientX < clientWidth - 400) {
el.style.left = clientX + 45; style.left = clientX + 45;
return el.style.right = null; return style.right = null;
} else { } else {
el.style.left = null; style.left = null;
return el.style.right = clientWidth - clientX + 45; return style.right = clientWidth - clientX + 45;
} }
}, },
hoverend: function(e) { hoverend: function(e) {

View File

@ -153,10 +153,11 @@ ui =
bottom = if top then null else 0 bottom = if top then null else 0
#using null instead of '' is 4% faster #using null instead of '' is 4% faster
#these 4 statements are 40% faster than 1 style.cssText #these 4 statements are 40% faster than 1 style.cssText
el.style.top = top {style} = el
el.style.right = right style.top = top
el.style.bottom = bottom style.right = right
el.style.left = left style.bottom = bottom
style.left = left
dragend: -> dragend: ->
#$ coffee -bpe '{a} = {b} = c' #$ coffee -bpe '{a} = {b} = c'
#var a, b; #var a, b;
@ -170,11 +171,12 @@ ui =
hover: (e) -> hover: (e) ->
{clientX, clientY} = e {clientX, clientY} = e
{el} = ui {el} = ui
{style} = el
{clientHeight, clientWidth} = d.body {clientHeight, clientWidth} = d.body
height = el.offsetHeight height = el.offsetHeight
top = clientY - 120 top = clientY - 120
el.style.top = style.top =
if clientHeight < height or top < 0 if clientHeight < height or top < 0
0 0
else if top + height > clientHeight else if top + height > clientHeight
@ -183,11 +185,11 @@ ui =
top top
if clientX < clientWidth - 400 if clientX < clientWidth - 400
el.style.left = clientX + 45 style.left = clientX + 45
el.style.right = null style.right = null
else else
el.style.left = null style.left = null
el.style.right = clientWidth - clientX + 45 style.right = clientWidth - clientX + 45
hoverend: (e) -> hoverend: (e) ->
ui.el.parentNode.removeChild ui.el ui.el.parentNode.removeChild ui.el