diff --git a/4chan_x.user.js b/4chan_x.user.js index c56782b70..4f9661067 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -232,19 +232,11 @@ drag: function(e) { var bottom, left, right, style, top; 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; - if (top < 10) { - top = '0'; - } else if (ui.height - top < 10) { - top = null; - } - bottom = top ? null : 0; + left = left < 10 ? 0 : ui.width - left < 10 ? null : left; + top = top < 10 ? 0 : ui.height - top < 10 ? null : top; + right = left === null ? 0 : null; + bottom = top === null ? 0 : null; style = ui.el.style; style.top = top; style.right = right; diff --git a/script.coffee b/script.coffee index ec8467fff..0db57fb60 100644 --- a/script.coffee +++ b/script.coffee @@ -152,13 +152,17 @@ ui = ui.height = d.body.clientHeight - el.offsetHeight drag: (e) -> 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 - if top < 10 then top = '0' - else if ui.height - top < 10 then top = null - bottom = if top then null else 0 + left = + if left < 10 then 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 #these 4 statements are 40% faster than 1 style.cssText {style} = ui.el