mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Fix bug where highlight would not appear on the first target node when continuing drawing a way
This commit is contained in:
@@ -27,7 +27,7 @@ export function behaviorDraw(context) {
|
||||
|
||||
var keybinding = utilKeybinding('draw');
|
||||
|
||||
var hover = behaviorHover(context).altDisables(true).ignoreVertex(true)
|
||||
var _hover = behaviorHover(context).altDisables(true).ignoreVertex(true)
|
||||
.on('hover', context.ui().sidebar.hover);
|
||||
var tail = behaviorTail();
|
||||
var edit = behaviorEdit(context);
|
||||
@@ -195,7 +195,7 @@ export function behaviorDraw(context) {
|
||||
|
||||
|
||||
function behavior(selection) {
|
||||
context.install(hover);
|
||||
context.install(_hover);
|
||||
context.install(edit);
|
||||
|
||||
if (!context.inIntro() && !_usedTails[tail.text()]) {
|
||||
@@ -225,7 +225,7 @@ export function behaviorDraw(context) {
|
||||
|
||||
behavior.off = function(selection) {
|
||||
context.ui().sidebar.hover.cancel();
|
||||
context.uninstall(hover);
|
||||
context.uninstall(_hover);
|
||||
context.uninstall(edit);
|
||||
|
||||
if (!context.inIntro() && !_usedTails[tail.text()]) {
|
||||
@@ -253,6 +253,10 @@ export function behaviorDraw(context) {
|
||||
return behavior;
|
||||
};
|
||||
|
||||
behavior.hover = function() {
|
||||
return _hover;
|
||||
};
|
||||
|
||||
|
||||
return utilRebind(behavior, dispatch, 'on');
|
||||
}
|
||||
|
||||
@@ -17,15 +17,16 @@ import { modeBrowse, modeSelect } from '../modes';
|
||||
import { osmNode } from '../osm';
|
||||
import { utilKeybinding } from '../util';
|
||||
|
||||
import _isEmpty from 'lodash-es/isEmpty';
|
||||
|
||||
export function behaviorDrawWay(context, wayId, index, mode, startGraph) {
|
||||
var origWay = context.entity(wayId);
|
||||
var annotation = t((origWay.isDegenerate() ?
|
||||
'operations.start.annotation.' :
|
||||
'operations.continue.annotation.') + context.geometry(wayId)
|
||||
);
|
||||
|
||||
var behavior = behaviorDraw(context);
|
||||
behavior.hover().initialNodeId(index ? origWay.nodes[index] : origWay.nodes[origWay.nodes.length - 1]);
|
||||
|
||||
var _tempEdits = 0;
|
||||
|
||||
var end = osmNode({ loc: context.map().mouseCoordinates() });
|
||||
@@ -67,7 +68,7 @@ export function behaviorDrawWay(context, wayId, index, mode, startGraph) {
|
||||
}
|
||||
|
||||
function allowsVertex(d) {
|
||||
return _isEmpty(d.tags) || context.presets().allowsVertex(d, context.graph());
|
||||
return context.presets().allowsVertex(d, context.graph());
|
||||
}
|
||||
|
||||
// related code
|
||||
|
||||
@@ -20,7 +20,8 @@ import { utilKeybinding, utilRebind } from '../util';
|
||||
export function behaviorHover(context) {
|
||||
var dispatch = d3_dispatch('hover');
|
||||
var _selection = d3_select(null);
|
||||
var _newId = null;
|
||||
var _newNodeId = null;
|
||||
var _initialNodeId = null;
|
||||
var _buttonDown;
|
||||
var _altDisables;
|
||||
var _ignoreVertex;
|
||||
@@ -57,7 +58,13 @@ export function behaviorHover(context) {
|
||||
|
||||
function behavior(selection) {
|
||||
_selection = selection;
|
||||
_newId = null;
|
||||
|
||||
if (_initialNodeId) {
|
||||
_newNodeId = _initialNodeId;
|
||||
_initialNodeId = null;
|
||||
} else {
|
||||
_newNodeId = null;
|
||||
}
|
||||
|
||||
_selection
|
||||
.on('mouseover.hover', mouseover)
|
||||
@@ -134,11 +141,11 @@ export function behaviorHover(context) {
|
||||
}
|
||||
|
||||
// Update hover state and dispatch event
|
||||
if (entity && entity.id !== _newId) {
|
||||
if (entity && entity.id !== _newNodeId) {
|
||||
// If drawing a way, don't hover on a node that was just placed. #3974
|
||||
var mode = context.mode() && context.mode().id;
|
||||
if ((mode === 'draw-line' || mode === 'draw-area') && !_newId && entity.type === 'node') {
|
||||
_newId = entity.id;
|
||||
if ((mode === 'draw-line' || mode === 'draw-area') && !_newNodeId && entity.type === 'node') {
|
||||
_newNodeId = entity.id;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,5 +194,10 @@ export function behaviorHover(context) {
|
||||
return behavior;
|
||||
};
|
||||
|
||||
behavior.initialNodeId = function(nodeId) {
|
||||
_initialNodeId = nodeId;
|
||||
return behavior;
|
||||
};
|
||||
|
||||
return utilRebind(behavior, dispatch, 'on');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user