mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-30 08:50:32 +02:00
Don't hover sidebar or vertices when alt key disables snapping
This makes it a little more clear that the alt key is doing its job
This commit is contained in:
@@ -92,6 +92,15 @@ g.vertex.vertex-hover {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.mode-draw-area .hover-disabled g.vertex.vertex-hover,
|
||||
.mode-draw-line .hover-disabled g.vertex.vertex-hover,
|
||||
.mode-add-area .hover-disabled g.vertex.vertex-hover,
|
||||
.mode-add-line .hover-disabled g.vertex.vertex-hover,
|
||||
.mode-add-point .hover-disabled g.vertex.vertex-hover,
|
||||
.mode-drag-node .hover-disabled g.vertex.vertex-hover {
|
||||
display: none;
|
||||
}
|
||||
|
||||
g.vertex.related:not(.selected) .shadow,
|
||||
g.vertex.hover:not(.selected) .shadow,
|
||||
g.midpoint.related:not(.selected) .shadow,
|
||||
|
||||
@@ -15,7 +15,7 @@ import { utilRebind } from '../util/rebind';
|
||||
*/
|
||||
export function behaviorHover() {
|
||||
var dispatch = d3.dispatch('hover'),
|
||||
selection = d3.select(null),
|
||||
_selection = d3.select(null),
|
||||
buttonDown,
|
||||
altDisables,
|
||||
target;
|
||||
@@ -23,28 +23,36 @@ export function behaviorHover() {
|
||||
|
||||
function keydown() {
|
||||
if (altDisables && d3.event.keyCode === d3keybinding.modifierCodes.alt) {
|
||||
dispatch.call('hover', this, null);
|
||||
selection.selectAll('.hover')
|
||||
_selection.selectAll('.hover')
|
||||
.classed('hover-suppressed', true)
|
||||
.classed('hover', false);
|
||||
|
||||
_selection
|
||||
.classed('hover-disabled', true);
|
||||
|
||||
dispatch.call('hover', this, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function keyup() {
|
||||
if (altDisables && d3.event.keyCode === d3keybinding.modifierCodes.alt) {
|
||||
dispatch.call('hover', this, target ? target.id : null);
|
||||
selection.selectAll('.hover-suppressed')
|
||||
_selection.selectAll('.hover-suppressed')
|
||||
.classed('hover-suppressed', false)
|
||||
.classed('hover', true);
|
||||
|
||||
_selection
|
||||
.classed('hover-disabled', false);
|
||||
|
||||
dispatch.call('hover', this, target ? target.id : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var hover = function(__) {
|
||||
selection = __;
|
||||
var hover = function(selection) {
|
||||
_selection = selection;
|
||||
|
||||
selection
|
||||
_selection
|
||||
.on('mouseover.hover', mouseover)
|
||||
.on('mouseout.hover', mouseout)
|
||||
.on('mousedown.hover', mousedown);
|
||||
@@ -86,9 +94,9 @@ export function behaviorHover() {
|
||||
if (d === target) return;
|
||||
target = d;
|
||||
|
||||
selection.selectAll('.hover')
|
||||
_selection.selectAll('.hover')
|
||||
.classed('hover', false);
|
||||
selection.selectAll('.hover-suppressed')
|
||||
_selection.selectAll('.hover-suppressed')
|
||||
.classed('hover-suppressed', false);
|
||||
|
||||
if (target instanceof osmEntity) {
|
||||
@@ -102,10 +110,11 @@ export function behaviorHover() {
|
||||
|
||||
var suppressed = altDisables && d3.event && d3.event.altKey;
|
||||
|
||||
selection.selectAll(selector)
|
||||
_selection.selectAll(selector)
|
||||
.classed(suppressed ? 'hover-suppressed' : 'hover', true);
|
||||
|
||||
dispatch.call('hover', this, target.id);
|
||||
dispatch.call('hover', this, !suppressed && target.id);
|
||||
|
||||
} else {
|
||||
dispatch.call('hover', this, null);
|
||||
}
|
||||
@@ -114,13 +123,13 @@ export function behaviorHover() {
|
||||
};
|
||||
|
||||
|
||||
hover.off = function(selection) {
|
||||
selection.selectAll('.hover')
|
||||
hover.off = function() {
|
||||
_selection.selectAll('.hover')
|
||||
.classed('hover', false);
|
||||
selection.selectAll('.hover-suppressed')
|
||||
_selection.selectAll('.hover-suppressed')
|
||||
.classed('hover-suppressed', false);
|
||||
|
||||
selection
|
||||
_selection
|
||||
.on('mouseover.hover', null)
|
||||
.on('mouseout.hover', null)
|
||||
.on('mousedown.hover', null);
|
||||
|
||||
@@ -70,6 +70,12 @@ describe('iD.behaviorHover', function() {
|
||||
expect(container.selectAll('.hover').nodes()).to.have.length(0);
|
||||
expect(container.selectAll('.hover-suppressed').nodes()).to.have.length(1);
|
||||
});
|
||||
|
||||
it('adds the .hover-disabled class to the surface', function () {
|
||||
container.call(iD.behaviorHover(context).altDisables(true));
|
||||
happen.keydown(window, {keyCode: 18});
|
||||
expect(container.classed('hover-disabled')).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
describe('alt keyup', function () {
|
||||
@@ -82,5 +88,12 @@ describe('iD.behaviorHover', function() {
|
||||
expect(container.selectAll('.hover').nodes()).to.have.length(1);
|
||||
expect(container.selectAll('.hover-suppressed').nodes()).to.have.length(0);
|
||||
});
|
||||
|
||||
it('removes the .hover-disabled class from the surface', function () {
|
||||
container.call(iD.behaviorHover(context).altDisables(true));
|
||||
happen.keydown(window, {keyCode: 18});
|
||||
happen.keyup(window, {keyCode: 18});
|
||||
expect(container.classed('hover-disabled')).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user