From 67950ec135186584b5b8b61281436c02e3bdf3a4 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sat, 30 May 2015 13:44:55 -0400 Subject: [PATCH] minor code review --- src/js/scriptlets/element-picker.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/js/scriptlets/element-picker.js b/src/js/scriptlets/element-picker.js index 7c8c25d7e..0d98f10ce 100644 --- a/src/js/scriptlets/element-picker.js +++ b/src/js/scriptlets/element-picker.js @@ -737,22 +737,20 @@ var elementFromPoint = function(x, y) { var onSvgHovered = (function() { var timer = null; - var position = { x: 0, y: 0 }; + var mx = 0, my = 0; var onTimer = function() { timer = null; - var elem = elementFromPoint(position.x, position.y); + var elem = elementFromPoint(mx, my); highlightElements(elem ? [elem] : []); }; var onMove = function(ev) { - position.x = ev.clientX; - position.y = ev.clientY; - if ( timer !== null ) { - return; + mx = ev.clientX; + my = ev.clientY; + if ( timer === null ) { + timer = vAPI.setTimeout(onTimer, 40); } - - timer = vAPI.setTimeout(onTimer, 40); }; return onMove;