Skip to content

Commit

Permalink
Only adjust for body offset when necessary
Browse files Browse the repository at this point in the history
We only need to correct for the body offset when the body element opens
a new positioning context. DOM Elements only open new positioning
contexts if their CSS "position" property has been changed from the
default, "static" value.

Corrects the adder/widget positioning on normal pages, where the body's
position has not been messed with.
  • Loading branch information
nickstenning committed Apr 22, 2015
1 parent a767a11 commit d31553e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ var gettext = (function () {
// corner of the page (taking into account padding/margin/border on the body
// element as necessary).
function mousePosition(event) {
var offset = $(getGlobal().document.body).offset();
var body = getGlobal().document.body;
var offset = {top: 0, left: 0};

if ($(body).css('position') !== "static") {
offset = $(body).offset();
}

return {
top: event.pageY - offset.top,
left: event.pageX - offset.left
Expand Down

0 comments on commit d31553e

Please sign in to comment.