Skip to content

Commit

Permalink
Make sure mouse position is not a factor for .click() in IE 10
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Aug 5, 2015
1 parent 1eef1a7 commit 1a2fb4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/standard/gestures.html
Expand Up @@ -124,8 +124,8 @@
var bcr = t.getBoundingClientRect();
// use page x/y to account for scrolling
var x = ev.pageX, y = ev.pageY;
return (x >= bcr.left && x <= bcr.right) &&
(y >= bcr.top && y <= bcr.bottom);
// ev is a synthetic click if the position is outside the bounding box of the target
return !((x >= bcr.left && x <= bcr.right) && (y >= bcr.top && y <= bcr.bottom));
}
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions test/unit/gestures.html
Expand Up @@ -54,6 +54,8 @@
});

test('HTMLElement.click triggers tap', function() {
// put the element off screen to prevent x/y weirdness from .click()
app.style.cssText = 'position: absolute; left: -1000px; top: -1000px;';
// make a mousedown *very* far away to tickle the distance check
var ev = new CustomEvent('mousedown');
ev.clientX = 1e8;
Expand Down

0 comments on commit 1a2fb4d

Please sign in to comment.