Files
iD/modules/behavior/add_way.js
Quincy Morgan f8f69a777a Replace inconsistently-supported dblclick events with custom handler on platforms supporting pointer events
Fix issue where double-tap-to-zoom would not be properly disabled when drawing on touch devices (close #2128)
Support adding nodes to ways with double-tap with on touch devices (close #2677)
Support double-tap-to-zoom with styluses on touch devices
Don't accept double click/tap events if the taps are far apart
Don't re-enter modeSelect when clicking the selected feature again
2020-03-06 12:46:26 -08:00

48 lines
1.2 KiB
JavaScript

import { dispatch as d3_dispatch } from 'd3-dispatch';
import { behaviorDraw } from './draw';
import { modeBrowse } from '../modes/browse';
import { utilRebind } from '../util/rebind';
export function behaviorAddWay(context) {
var dispatch = d3_dispatch('start', 'startFromWay', 'startFromNode');
var draw = behaviorDraw(context);
function behavior(surface) {
draw.on('click', function() { dispatch.apply('start', this, arguments); })
.on('clickWay', function() { dispatch.apply('startFromWay', this, arguments); })
.on('clickNode', function() { dispatch.apply('startFromNode', this, arguments); })
.on('cancel', behavior.cancel)
.on('finish', behavior.cancel);
context.map()
.dblclickZoomEnable(false);
surface.call(draw);
}
behavior.off = function(surface) {
surface.call(draw.off);
};
behavior.cancel = function() {
window.setTimeout(function() {
context.map().dblclickZoomEnable(true);
}, 1000);
context.enter(modeBrowse(context));
};
behavior.tail = function(text) {
draw.tail(text);
return behavior;
};
return utilRebind(behavior, dispatch, 'on');
}