From 1ce1119de2f169bfb9783ada8f4e8c6602a0c9ea Mon Sep 17 00:00:00 2001 From: Guillaume Carbonneau Date: Thu, 18 Aug 2016 00:39:20 -0400 Subject: [PATCH] Performance improvement. Debounce redraw call. --- modules/renderer/map.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/renderer/map.js b/modules/renderer/map.js index 2d66a89f3..9cf105c13 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -217,8 +217,6 @@ export function Map(context) { function redraw(difference, extent) { if (!surface || !redrawEnabled) return; - 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. @@ -254,10 +252,7 @@ export function Map(context) { return map; } - var timeoutId; - function queueRedraw() { - timeoutId = setTimeout(function() { redraw(); }, 750); - } + var queueRedraw = _.debounce(redraw, 750); function pointLocation(p) { var translate = projection.translate(),