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.
This commit is contained in:
John Firebaugh
2013-02-13 14:26:21 -08:00
parent 8538339b44
commit 3be61a65e6

View File

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