From 15c6fe4220d2377e9cedee4d57d16873afa257df Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Tue, 16 Oct 2012 06:08:02 -0700 Subject: [PATCH] Use query instead of custom logic to figure out where we clicked. Works in IE9. --- examples/parties/client/client.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/examples/parties/client/client.js b/examples/parties/client/client.js index 3802b2d0ab9..d5dc73d6a1a 100644 --- a/examples/parties/client/client.js +++ b/examples/parties/client/client.js @@ -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 = {