Minor style adjustments, code cleanups

This commit is contained in:
Bryan Housel
2016-03-15 14:42:08 -04:00
parent 3da6b21e44
commit e0d7daad3a
3 changed files with 16 additions and 34 deletions

View File

@@ -2919,8 +2919,8 @@ div.full-screen > button:hover {
color: rgba(40,40,40,.5);
}
.lasso-box {
fill-opacity:0.1;
.lasso-path {
fill-opacity:0.3;
stroke: #fff;
stroke-width: 1;
stroke-opacity: 1;

View File

@@ -1,13 +1,10 @@
iD.behavior.Lasso = function(context) {
var behavior = function(selection) {
var mouse = null,
lasso;
var lasso;
function mousedown() {
if (d3.event.shiftKey === true) {
mouse = context.mouse();
lasso = null;
selection
@@ -20,7 +17,7 @@ iD.behavior.Lasso = function(context) {
function mousemove() {
if (!lasso) {
lasso = iD.ui.Lasso(context).p(mouse);
lasso = iD.ui.Lasso(context);
context.surface().call(lasso);
}
@@ -41,9 +38,8 @@ iD.behavior.Lasso = function(context) {
if (!lasso) return;
var graph = context.graph(),
extent = iD.geo.Extent(
normalize(context.projection.invert(lasso.getBounds()[0]),
context.projection.invert(lasso.getBounds()[1])));
bounds = lasso.extent().map(context.projection.invert),
extent = iD.geo.Extent(normalize(bounds[0], bounds[1]));
lasso.close();

View File

@@ -1,7 +1,5 @@
iD.ui.Lasso = function(context) {
var group, path,
polygon, p;
var group, polygon;
lasso.coordinates = [];
@@ -13,45 +11,33 @@ iD.ui.Lasso = function(context) {
.attr('class', 'lasso hide');
polygon = group.append('path')
.attr('class', 'lasso-box');
.attr('class', 'lasso-path');
group.call(iD.ui.Toggle(true));
}
// top-left
function topLeft(d) {
return path = (path ? (path + ' L ') : 'M ') + d[0] + ' ' + d[1];
}
function draw() {
if (polygon) {
polygon.data([p])
.attr('d', topLeft);
polygon.data([lasso.coordinates])
.attr('d', function(d) { return 'M' + d.join(' L') + ' Z'; });
}
}
lasso.getBounds = function () {
var x = lasso.coordinates.map(function(i) {return i[0];});
var y = lasso.coordinates.map(function(i) {return i[1];});
return [[Math.min.apply(null, x), Math.min.apply(null, y)],
[Math.max.apply(null, x), Math.max.apply(null, y)]];
lasso.extent = function () {
return lasso.coordinates.reduce(function(extent, point) {
return extent.extend(iD.geo.Extent(point));
}, iD.geo.Extent());
};
lasso.p = function(_) {
if (!arguments.length) return p;
p = _;
lasso.coordinates.push(p);
if (!arguments.length) return lasso;
lasso.coordinates.push(_);
draw();
return lasso;
};
lasso.close = function() {
polygon.data([p])
.attr('d', path + ' Z');
if (group) {
group.call(iD.ui.Toggle(false, function() {
d3.select(this).remove();