Files
iD/modules/modes/draw_line.js
Quincy Morgan 869a0c6b89 Make the draw modes reuse their behaviorDraw when re-entering
Move click-end-node-to-finish functionality from draw modes to behaviorDraw
Fix issue where the head node would get hover-highlighted when continuing from the end of a line
2020-05-22 15:05:35 -04:00

42 lines
967 B
JavaScript

import { t } from '../core/localizer';
import { behaviorDrawWay } from '../behavior/draw_way';
export function modeDrawLine(context, wayID, startGraph, button, affix, continuing) {
var mode = {
button: button,
id: 'draw-line'
};
var behavior = behaviorDrawWay(context, wayID, mode, startGraph)
.on('rejectedSelfIntersection.modeDrawLine', function() {
context.ui().flash
.text(t('self_intersection.error.lines'))();
});
mode.wayID = wayID;
mode.isContinuing = continuing;
mode.enter = function() {
behavior
.nodeIndex(affix === 'prefix' ? 0 : undefined);
context.install(behavior);
};
mode.exit = function() {
context.uninstall(behavior);
};
mode.selectedIDs = function() {
return [wayID];
};
mode.activeID = function() {
return (behavior && behavior.activeID()) || [];
};
return mode;
}