mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
If drawing a way, don't hover on a node that was just placed
(closes #3974)
This commit is contained in:
@@ -13,9 +13,10 @@ import { utilRebind } from '../util/rebind';
|
||||
Only one of these elements can have the :hover pseudo-class, but all of them will
|
||||
have the .hover class.
|
||||
*/
|
||||
export function behaviorHover() {
|
||||
export function behaviorHover(context) {
|
||||
var dispatch = d3.dispatch('hover'),
|
||||
_selection = d3.select(null),
|
||||
newNode = null,
|
||||
buttonDown,
|
||||
altDisables,
|
||||
target;
|
||||
@@ -51,6 +52,7 @@ export function behaviorHover() {
|
||||
|
||||
var hover = function(selection) {
|
||||
_selection = selection;
|
||||
newNode = null;
|
||||
|
||||
_selection
|
||||
.on('mouseover.hover', mouseover)
|
||||
@@ -99,7 +101,15 @@ export function behaviorHover() {
|
||||
_selection.selectAll('.hover-suppressed')
|
||||
.classed('hover-suppressed', false);
|
||||
|
||||
if (target instanceof osmEntity) {
|
||||
if (target instanceof osmEntity && target !== newNode) {
|
||||
|
||||
// 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') && !newNode && target.type === 'node') {
|
||||
newNode = target;
|
||||
return;
|
||||
}
|
||||
|
||||
var selector = '.' + target.id;
|
||||
|
||||
if (target.type === 'relation') {
|
||||
|
||||
@@ -17,7 +17,8 @@ export function svgMidpoints(projection, context) {
|
||||
return function drawMidpoints(selection, graph, entities, filter, extent) {
|
||||
var layer = selection.selectAll('.layer-hit');
|
||||
|
||||
if (context.mode().id !== 'select') {
|
||||
var mode = context.mode();
|
||||
if (mode && mode.id !== 'select') {
|
||||
layer.selectAll('g.midpoint').remove();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ describe('iD.behaviorHover', function() {
|
||||
beforeEach(function() {
|
||||
container = d3.select('body').append('div');
|
||||
context = {
|
||||
hover: function() {}
|
||||
hover: function() {},
|
||||
mode: function() { return { id: 'browse' }; }
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
describe('iD.Map', function() {
|
||||
var context, map;
|
||||
var content, context, map;
|
||||
|
||||
beforeEach(function() {
|
||||
content = d3.select('body').append('div');
|
||||
context = iD.Context();
|
||||
context.container(d3.select(document.createElement('div')));
|
||||
map = context.map();
|
||||
d3.select(document.createElement('div'))
|
||||
.call(map);
|
||||
content.call(map);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
content.remove();
|
||||
});
|
||||
|
||||
describe('#zoom', function() {
|
||||
|
||||
Reference in New Issue
Block a user