mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 13:18:15 +02:00
Variable cleanups in behavior and modes
This commit is contained in:
+17
-16
@@ -15,8 +15,9 @@ import {
|
||||
|
||||
import {
|
||||
geoExtent,
|
||||
geoPointInPolygon
|
||||
} from '../geo/';
|
||||
geoPointInPolygon,
|
||||
geoVecSubtract
|
||||
} from '../geo';
|
||||
|
||||
import { modeMove } from '../modes';
|
||||
import { uiCmd } from '../ui';
|
||||
@@ -29,17 +30,17 @@ export function behaviorPaste(context) {
|
||||
function doPaste() {
|
||||
d3_event.preventDefault();
|
||||
|
||||
var baseGraph = context.graph(),
|
||||
mouse = context.mouse(),
|
||||
projection = context.projection,
|
||||
viewport = geoExtent(projection.clipExtent()).polygon();
|
||||
var baseGraph = context.graph();
|
||||
var mouse = context.mouse();
|
||||
var projection = context.projection;
|
||||
var viewport = geoExtent(projection.clipExtent()).polygon();
|
||||
|
||||
if (!geoPointInPolygon(mouse, viewport)) return;
|
||||
|
||||
var extent = geoExtent(),
|
||||
oldIDs = context.copyIDs(),
|
||||
oldGraph = context.copyGraph(),
|
||||
newIDs = [];
|
||||
var extent = geoExtent();
|
||||
var oldIDs = context.copyIDs();
|
||||
var oldGraph = context.copyGraph();
|
||||
var newIDs = [];
|
||||
|
||||
if (!oldIDs.length) return;
|
||||
|
||||
@@ -49,14 +50,14 @@ export function behaviorPaste(context) {
|
||||
var copies = action.copies();
|
||||
var originals = _invert(_mapValues(copies, 'id'));
|
||||
for (var id in copies) {
|
||||
var oldEntity = oldGraph.entity(id),
|
||||
newEntity = copies[id];
|
||||
var oldEntity = oldGraph.entity(id);
|
||||
var newEntity = copies[id];
|
||||
|
||||
extent._extend(oldEntity.extent(oldGraph));
|
||||
|
||||
// Exclude child nodes from newIDs if their parent way was also copied.
|
||||
var parents = context.graph().parentWays(newEntity),
|
||||
parentCopied = false;
|
||||
var parents = context.graph().parentWays(newEntity);
|
||||
var parentCopied = false;
|
||||
for (var i = 0; i < parents.length; i++) {
|
||||
if (originals[parents[i].id]) {
|
||||
parentCopied = true;
|
||||
@@ -70,8 +71,8 @@ export function behaviorPaste(context) {
|
||||
}
|
||||
|
||||
// Put pasted objects where mouse pointer is..
|
||||
var center = projection(extent.center()),
|
||||
delta = [ mouse[0] - center[0], mouse[1] - center[1] ];
|
||||
var center = projection(extent.center());
|
||||
var delta = geoVecSubtract(mouse, center);
|
||||
|
||||
context.perform(actionMove(newIDs, delta, projection));
|
||||
context.enter(modeMove(context, newIDs, baseGraph));
|
||||
|
||||
Reference in New Issue
Block a user