Adjust double click handler for new D3 zoom behavior

D3 v3.5+ has changed the zoom behavior to emit tweened zoom events
rather than a single zoom event with a dblclick source event.
This commit is contained in:
Bryan Housel
2015-03-07 15:22:37 -05:00
parent 81798423c0
commit b4cd1d67d8
+9 -8
View File
@@ -30,7 +30,9 @@ iD.Map = function(context) {
context.features()
.on('redraw.map', redraw);
selection.call(zoom);
selection
.on('dblclick.map', dblClick)
.call(zoom);
supersurface = selection.append('div')
.attr('id', 'supersurface');
@@ -143,15 +145,14 @@ iD.Map = function(context) {
dispatch.drawn({full: true});
}
function zoomPan() {
if (d3.event && d3.event.sourceEvent.type === 'dblclick') {
if (!dblclickEnabled) {
zoom.scale(projection.scale() * 2 * Math.PI)
.translate(projection.translate());
return d3.event.sourceEvent.preventDefault();
}
function dblClick() {
if (!dblclickEnabled) {
d3.event.preventDefault();
d3.event.stopImmediatePropagation();
}
}
function zoomPan() {
if (Math.log(d3.event.scale / Math.LN2 - 8) < minzoom + 1) {
iD.ui.flash(context.container())
.select('.content')