Skip to content

Commit

Permalink
Use query instead of custom logic to figure out where we clicked. Wor…
Browse files Browse the repository at this point in the history
…ks in IE9.
  • Loading branch information
n1mmy committed Oct 16, 2012
1 parent 45955d3 commit 15c6fe4
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions examples/parties/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,12 @@ Template.attendance.canInvite = function () {
///////////////////////////////////////////////////////////////////////////////
// Map display

// http://stackoverflow.com/questions/55677/how-do-i-get-the-coordinates-of-a-mouse-click-on-a-canvas-element
// Use jquery to get the position clicked relative to the map element.
var coordsRelativeToElement = function (element, event) {
var totalOffsetX = 0, totalOffsetY = 0;

do {
totalOffsetX += element.offsetLeft - element.scrollLeft;
totalOffsetY += element.offsetTop - element.scrollTop;
} while (element = element.offsetParent);

return {
x: event.pageX - totalOffsetX,
y: event.pageY - totalOffsetY
};
var offset = $(element).offset();
var x = event.pageX - offset.left;
var y = event.pageY - offset.top;
return { x: x, y: y };
};

Template.map.events = {
Expand Down

0 comments on commit 15c6fe4

Please sign in to comment.