From 3be61a65e67efe83f814a32096c2c8ec1b072fc6 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 13 Feb 2013 14:26:21 -0800 Subject: [PATCH] Manual redraw debouncing This avoids a duplicate full redraw at the end of a drag pan. The redraw triggered by mouseup.zoom now cancels the pending debounced redraw. Also, bump the debounce interval to 300ms, which helps avoid full redraws during scroll zoom, making it more responsive. --- js/id/renderer/map.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 26ec19ebe..03562d3d8 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -146,6 +146,8 @@ iD.Map = function(context) { } function redraw(difference) { + clearTimeout(timeoutId); + // If we are in the middle of a zoom/pan, we can't do differenced redraws. // It would result in artifacts where differenced entities are redrawn with // one transform and unchanged entities with another. @@ -173,7 +175,11 @@ iD.Map = function(context) { return map; } - var queueRedraw = _.debounce(redraw, 200); + var timeoutId; + function queueRedraw() { + clearTimeout(timeoutId); + timeoutId = setTimeout(function() { redraw(); }, 300); + } function pointLocation(p) { var translate = projection.translate(),