coalesce mouse move events

This commit is contained in:
gorhill 2015-05-27 15:15:20 -04:00
parent a51422c3df
commit 56ac5a1105
1 changed files with 22 additions and 4 deletions

View File

@ -735,11 +735,29 @@ var elementFromPoint = function(x, y) {
/******************************************************************************/ /******************************************************************************/
var onSvgHovered = function(ev) { var onSvgHovered = (function() {
var elem = elementFromPoint(ev.clientX, ev.clientY); var timer = null;
var position = { x: 0, y: 0 };
var onTimer = function() {
timer = null;
var elem = elementFromPoint(position.x, position.y);
highlightElements(elem ? [elem] : []); highlightElements(elem ? [elem] : []);
}; };
var onMove = function(ev) {
position.x = ev.clientX;
position.y = ev.clientY;
if ( timer !== null ) {
return;
}
timer = vAPI.setTimeout(onTimer, 40);
};
return onMove;
})();
/******************************************************************************/ /******************************************************************************/
var onSvgClicked = function(ev) { var onSvgClicked = function(ev) {