mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-02 05:01:38 +02:00
7994baae23
The goal here is that the code that draws the targets should know better what parts of the lines/vertices are targetable, rather than just relying on CSS to ignore the pointer events on the whole line. e.g. when drawing a line, it's ok for it to loop back and connect to itself, just not on a segment or vertex adjacent to the active node.
56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
import { t } from '../util/locale';
|
|
import { behaviorDrawWay } from '../behavior';
|
|
|
|
|
|
export function modeDrawArea(context, wayId, startGraph) {
|
|
var mode = {
|
|
button: 'area',
|
|
id: 'draw-area'
|
|
};
|
|
|
|
var behavior;
|
|
|
|
|
|
mode.enter = function() {
|
|
var way = context.entity(wayId);
|
|
|
|
behavior = behaviorDrawWay(context, wayId, undefined, mode, startGraph)
|
|
.tail(t('modes.draw_area.tail'));
|
|
|
|
var addNode = behavior.addNode;
|
|
|
|
behavior.addNode = function(node) {
|
|
var length = way.nodes.length;
|
|
var penultimate = length > 2 ? way.nodes[length - 2] : null;
|
|
|
|
if (node.id === way.first() || node.id === penultimate) {
|
|
behavior.finish();
|
|
} else {
|
|
addNode(node);
|
|
}
|
|
};
|
|
|
|
context.install(behavior);
|
|
};
|
|
|
|
|
|
mode.exit = function() {
|
|
context.uninstall(behavior);
|
|
};
|
|
|
|
|
|
mode.selectedIDs = function() {
|
|
return [wayId];
|
|
};
|
|
|
|
// mode.activeIDs = function() {
|
|
// return (behavior && behavior.activeIDs()) || [];
|
|
// };
|
|
mode.activeID = function() {
|
|
return (behavior && behavior.activeID()) || [];
|
|
};
|
|
|
|
|
|
return mode;
|
|
}
|