From d50f7f13abe1bc286af54e27112687dd4a1cadb9 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 13 Feb 2013 12:03:41 -0800 Subject: [PATCH] Cache properties in fastMouse --- js/id/util.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/id/util.js b/js/id/util.js index bec8bc075..cfcf453a9 100644 --- a/js/id/util.js +++ b/js/id/util.js @@ -80,12 +80,14 @@ iD.util.getStyle = function(selector) { // 2. Does not cause style recalculation iD.util.fastMouse = function(container) { var rect = _.clone(container.getBoundingClientRect()), + rectLeft = rect.left, + rectTop = rect.top, clientLeft = +container.clientLeft, clientTop = +container.clientTop; return function(e) { return [ - e.clientX - rect.left - container.clientLeft, - e.clientY - rect.top - container.clientTop]; + e.clientX - rectLeft - clientLeft, + e.clientY - rectTop - clientTop]; }; };