mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-03 21:48:03 +02:00
Normalize coordinates so that lasso can be dragged in any direction
This commit is contained in:
+13
-6
@@ -28,25 +28,32 @@ iD.behavior.Lasso = function(context) {
|
||||
lasso.b(d3.mouse(context.surface().node()));
|
||||
}
|
||||
|
||||
function normalize(a, b) {
|
||||
return [
|
||||
[Math.min(a[0], b[0]), Math.min(a[1], b[1])],
|
||||
[Math.max(a[0], b[0]), Math.max(a[1], b[1])]];
|
||||
}
|
||||
|
||||
function mouseup() {
|
||||
var extent = iD.geo.Extent(
|
||||
context.projection.invert(lasso.a()),
|
||||
context.projection.invert(lasso.b()));
|
||||
normalize(context.projection.invert(lasso.a()),
|
||||
context.projection.invert(lasso.b())));
|
||||
|
||||
lasso.close();
|
||||
|
||||
var selected = context.graph().intersects(extent);
|
||||
|
||||
selection
|
||||
.on('mousemove.lasso', null)
|
||||
.on('mouseup.lasso', null);
|
||||
|
||||
if (selected.length) {
|
||||
context.enter(iD.modes.Select(context, _.pluck(selected, 'id')));
|
||||
}
|
||||
|
||||
selection
|
||||
.on('mousemove.lasso', null);
|
||||
}
|
||||
|
||||
selection
|
||||
.on('mousedown.select', mousedown);
|
||||
.on('mousedown.lasso', mousedown);
|
||||
};
|
||||
|
||||
behavior.off = function(selection) {
|
||||
|
||||
Reference in New Issue
Block a user