disable reset button when background not offset

also, only start the fast adjustment after 500ms to
prevent slow clicks from triggering multiple nudges

fixes #1312
This commit is contained in:
Ansis Brammanis
2013-04-16 22:58:13 -04:00
parent 63f2df89b3
commit 690f2d94a5
+10 -2
View File
@@ -140,15 +140,22 @@ iD.ui.Background = function(context) {
}
function clickNudge(d) {
var interval = window.setInterval(nudge, 100);
var timeout = window.setTimeout(function() {
interval = window.setInterval(nudge, 100);
}, 500),
interval;
d3.select(this).on('mouseup', function() {
window.clearInterval(interval);
window.clearTimeout(timeout);
nudge();
});
function nudge() {
context.background().nudge(d[1], context.map().zoom());
var offset = context.background().offset();
resetButton.classed('disabled', offset[0] === 0 && offset[1] === 0);
context.redraw();
}
}
@@ -302,9 +309,10 @@ iD.ui.Background = function(context) {
.on('mousedown', clickNudge);
var resetButton = nudgeContainer.append('button')
.attr('class', 'reset')
.attr('class', 'reset disabled')
.on('click', function () {
context.background().offset([0, 0]);
resetButton.classed('disabled', true);
context.redraw();
});