Less declarations in ui.drag(e)

This commit is contained in:
Nicolas Stepien 2011-10-18 19:07:40 +02:00
parent b3c4dc3d8b
commit b481304339
2 changed files with 14 additions and 18 deletions

View File

@ -232,19 +232,11 @@
drag: function(e) { drag: function(e) {
var bottom, left, right, style, top; var bottom, left, right, style, top;
left = e.clientX - ui.dx; left = e.clientX - ui.dx;
if (left < 10) {
left = '0';
} else if (ui.width - left < 10) {
left = null;
}
right = left ? null : 0;
top = e.clientY - ui.dy; top = e.clientY - ui.dy;
if (top < 10) { left = left < 10 ? 0 : ui.width - left < 10 ? null : left;
top = '0'; top = top < 10 ? 0 : ui.height - top < 10 ? null : top;
} else if (ui.height - top < 10) { right = left === null ? 0 : null;
top = null; bottom = top === null ? 0 : null;
}
bottom = top ? null : 0;
style = ui.el.style; style = ui.el.style;
style.top = top; style.top = top;
style.right = right; style.right = right;

View File

@ -152,13 +152,17 @@ ui =
ui.height = d.body.clientHeight - el.offsetHeight ui.height = d.body.clientHeight - el.offsetHeight
drag: (e) -> drag: (e) ->
left = e.clientX - ui.dx left = e.clientX - ui.dx
if left < 10 then left = '0'
else if ui.width - left < 10 then left = null
right = if left then null else 0
top = e.clientY - ui.dy top = e.clientY - ui.dy
if top < 10 then top = '0' left =
else if ui.height - top < 10 then top = null if left < 10 then 0
bottom = if top then null else 0 else if ui.width - left < 10 then null
else left
top =
if top < 10 then 0
else if ui.height - top < 10 then null
else top
right = if left is null then 0 else null
bottom = if top is null then 0 else null
#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
{style} = ui.el {style} = ui.el