Performance improvement. Debounce redraw call.

This commit is contained in:
Guillaume Carbonneau
2016-08-18 00:39:20 -04:00
parent 13ed12c1ab
commit 1ce1119de2

View File

@@ -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(),