Fix lasso and add it to select

This commit is contained in:
Ansis Brammanis
2013-02-08 17:46:37 -05:00
parent 123c700853
commit ba47d3183d
3 changed files with 7 additions and 3 deletions

View File

@@ -22,8 +22,8 @@ iD.behavior.Select = function(context) {
function mousedown() {
var datum = d3.event.target.__data__;
pos = [d3.event.x, d3.event.y];
if (datum instanceof iD.Entity || (datum && datum.type === 'midpoint')) {
pos = [d3.event.x, d3.event.y];
selection
.on('mousemove.select', mousemove)
.on('touchmove.select', mousemove);
@@ -46,8 +46,6 @@ iD.behavior.Select = function(context) {
// save the event for the click handler
})(d3.event), 200);
}
} else {
context.enter(iD.modes.Browse(context));
}
}
@@ -61,6 +59,10 @@ iD.behavior.Select = function(context) {
function mouseup() {
selection.on('mousemove.select', null);
if (d3.event.x === pos[0] && d3.event.y === pos[1] &&
!(d3.event.target.__data__ instanceof iD.Entity)) {
context.enter(iD.modes.Browse(context));
}
}
selection

View File

@@ -9,6 +9,7 @@ iD.modes.Select = function(context, selection, initial) {
behaviors = [
iD.behavior.Hover(),
iD.behavior.Select(context),
iD.behavior.Lasso(context),
iD.behavior.DragNode(context)],
radialMenu;

View File

@@ -42,6 +42,7 @@ describe("iD.behavior.Select", function() {
context.enter(iD.modes.Select(context, [a.id]));
happen.click(context.surface().node());
happen.mousedown(context.surface().node());
happen.mouseup(context.surface().node());
window.setTimeout(function() {
expect(context.selection()).to.eql([]);
done();