Skip to content

Commit

Permalink
Allow movement of any node that is in the selectedIDs list..
Browse files Browse the repository at this point in the history
(closes #3195)
  • Loading branch information
bhousel committed Jul 25, 2016
1 parent f4979db commit 2450782
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions modules/actions/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ export function Move(moveIds, tryDelta, projection, cache) {

function setupCache(graph) {
function canMove(nodeId) {
// Allow movement of any node that is in the selectedIDs list..
if (moveIds.indexOf(nodeId) !== -1) return true;

// Allow movement of a vertex where 2 ways meet..
var parents = _.map(graph.parentWays(graph.entity(nodeId)), 'id');
if (parents.length < 3) return true;

// Don't move a vertex where >2 ways meet, unless all parentWays are moving too..
// Restrict movement of a vertex where >2 ways meet, unless all parentWays are moving too..
var parentsMoving = _.every(parents, function(id) { return cache.moving[id]; });
if (!parentsMoving) delete cache.moving[nodeId];

return parentsMoving;
}

function cacheEntities(ids) {
_.each(ids, function(id) {
ids.forEach(function(id) {
if (cache.moving[id]) return;
cache.moving[id] = true;

Expand All @@ -44,17 +48,20 @@ export function Move(moveIds, tryDelta, projection, cache) {
cache.ways.push(id);
cacheEntities(entity.nodes);
} else {
cacheEntities(_.map(entity.members, 'id'));
cacheEntities(entity.members.map(function(member) {
return member.id;
}));
}
});
}

function cacheIntersections(ids) {
function isEndpoint(way, id) { return !way.isClosed() && !!way.affix(id); }

_.each(ids, function(id) {
ids.forEach(function(id) {
// consider only intersections with 1 moved and 1 unmoved way.
_.each(graph.childNodes(graph.entity(id)), function(node) {
var childNodes = graph.childNodes(graph.entity(id));
childNodes.forEach(function(node) {
var parents = graph.parentWays(node);
if (parents.length !== 2) return;

Expand Down

0 comments on commit 2450782

Please sign in to comment.