Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix offset bug when top-most body has margins/padding.

References #56 - "improve the touch/pointer coordinates calculations".
  • Loading branch information...
commit b7fb937db02bcb8dbca90dbd9832274288d19270 1 parent 504cd9d
@joseph authored
Showing with 3 additions and 3 deletions.
  1. +2 −2 src/core/events.js
  2. +1 −1  test/tests.css
View
4 src/core/events.js
@@ -99,11 +99,11 @@ Monocle.Events.listenForContact = function (elem, fns, options) {
var r;
if (elem.getBoundingClientRect) {
var er = elem.getBoundingClientRect();
- var dr = document.body.getBoundingClientRect();
+ var dr = document.documentElement.getBoundingClientRect();
r = { left: er.left - dr.left, top: er.top - dr.top };
} else {
r = { left: elem.offsetLeft, top: elem.offsetTop }
- while (elem = elem.parentNode) {
+ while (elem = elem.offsetParent) {
if (elem.offsetLeft || elem.offsetTop) {
r.left += elem.offsetLeft;
r.top += elem.offsetTop;
View
2  test/tests.css
@@ -15,7 +15,7 @@ h1 {
body.narrow {
max-width: 25em;
- /*margin: 0 auto;*/
+ margin: 0 auto;
}
h1, h2, h3, p, li {
Please sign in to comment.
Something went wrong with that request. Please try again.