draw_way only applies to currently selected way

This commit is contained in:
Ansis Brammanis
2013-01-15 13:12:05 -05:00
parent e35ac698a3
commit 91a709685c
2 changed files with 13 additions and 2 deletions
+10 -2
View File
@@ -22,7 +22,8 @@ iD.behavior.drag = function () {
var event = d3.dispatch("start", "move", "end"),
origin = null,
selector = '';
selector = '',
filter = null;
event.of = function(thiz, argumentz) {
return function(e1) {
@@ -119,7 +120,8 @@ iD.behavior.drag = function () {
var root = this,
target = d3.event.target;
for (; target && target !== root; target = target.parentNode) {
if (target[matchesSelector](selector)) {
if (target[matchesSelector](selector) &&
(!filter || filter(target.__data__))) {
return mousedown.call(target, target.__data__);
}
}
@@ -141,6 +143,12 @@ iD.behavior.drag = function () {
return drag;
};
drag.filter = function(_) {
if (!arguments.length) return origin;
filter = _;
return drag;
};
drag.origin = function (_) {
if (!arguments.length) return origin;
origin = _;
+3
View File
@@ -4,6 +4,9 @@ iD.behavior.DragWay = function(mode) {
return iD.behavior.drag()
.delegate('.casing, .stroke, .area')
.filter(function(d) {
return d && d.id === mode.entity.id;
})
.origin(function(entity) {
return projection(entity.nodes[0].loc);
})