diff --git a/4chan_x.js b/4chan_x.js index 40d13ce5a..a9bc8939a 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -183,10 +183,11 @@ return el; }, move: function(e) { - var el; + var el, rect; el = ui.el; - ui.dx = e.clientX - el.offsetLeft; - ui.dy = e.clientY - el.offsetTop; + rect = el.getBoundingClientRect(); + ui.dx = e.clientX - rect.left; + ui.dy = e.clientY - rect.top; ui.width = document.body.clientWidth - el.offsetWidth; ui.height = document.body.clientHeight - el.offsetHeight; document.addEventListener('mousemove', ui.moveMove, true); diff --git a/script.coffee b/script.coffee index abb8bda05..448db70c3 100644 --- a/script.coffee +++ b/script.coffee @@ -100,8 +100,10 @@ ui = move: (e) -> {el} = ui #distance from pointer to el edge is constant; calculate it here. - ui.dx = e.clientX - el.offsetLeft - ui.dy = e.clientY - el.offsetTop + # XXX opera reports el.offsetLeft / el.offsetTop as 0 + rect = el.getBoundingClientRect() + ui.dx = e.clientX - rect.left + ui.dy = e.clientY - rect.top #factor out el from document dimensions ui.width = document.body.clientWidth - el.offsetWidth ui.height = document.body.clientHeight - el.offsetHeight