mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-22 11:03:28 +00:00
Use context.mouse()
This commit is contained in:
@@ -58,7 +58,7 @@ iD.behavior.Draw = function(context) {
|
||||
function click() {
|
||||
var d = datum();
|
||||
if (d.type === 'way') {
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(d), d3.mouse(context.surface().node()), context.projection),
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection),
|
||||
edge = [d.nodes[choice.index - 1], d.nodes[choice.index]];
|
||||
event.clickWay(choice.loc, edge);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ iD.behavior.DrawWay = function(context, wayId, index, mode, baseGraph) {
|
||||
} else if (datum.type === 'node') {
|
||||
loc = datum.loc;
|
||||
} else if (datum.type === 'way') {
|
||||
loc = iD.geo.chooseEdge(context.childNodes(datum), d3.mouse(context.surface().node()), context.projection).loc;
|
||||
loc = iD.geo.chooseEdge(context.childNodes(datum), context.mouse(), context.projection).loc;
|
||||
}
|
||||
|
||||
context.replace(iD.actions.MoveNode(end.id, loc));
|
||||
|
||||
@@ -8,7 +8,7 @@ iD.behavior.Lasso = function(context) {
|
||||
function mousedown() {
|
||||
if (d3.event.shiftKey === true) {
|
||||
|
||||
mouse = d3.mouse(context.surface().node());
|
||||
mouse = context.mouse();
|
||||
lasso = null;
|
||||
|
||||
selection
|
||||
@@ -27,7 +27,7 @@ iD.behavior.Lasso = function(context) {
|
||||
context.surface().call(lasso);
|
||||
}
|
||||
|
||||
lasso.b(d3.mouse(context.surface().node()));
|
||||
lasso.b(context.mouse());
|
||||
}
|
||||
|
||||
function normalize(a, b) {
|
||||
|
||||
@@ -138,6 +138,7 @@ window.iD = function () {
|
||||
context.layers = function() { return map.layers; };
|
||||
context.background = function() { return map.layers[0]; };
|
||||
context.surface = function() { return map.surface; };
|
||||
context.mouse = map.mouse;
|
||||
context.projection = map.projection;
|
||||
context.tail = map.tail;
|
||||
context.redraw = map.redraw;
|
||||
|
||||
@@ -101,7 +101,7 @@ iD.modes.DragNode = function(context) {
|
||||
if (d.type === 'node' && d.id !== entity.id) {
|
||||
loc = d.loc;
|
||||
} else if (d.type === 'way') {
|
||||
loc = iD.geo.chooseEdge(context.childNodes(d), d3.mouse(context.surface().node()), context.projection).loc;
|
||||
loc = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection).loc;
|
||||
}
|
||||
|
||||
context.replace(
|
||||
@@ -115,7 +115,7 @@ iD.modes.DragNode = function(context) {
|
||||
var d = datum();
|
||||
|
||||
if (d.type === 'way') {
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(d), d3.mouse(context.surface().node()), context.projection);
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection);
|
||||
context.replace(
|
||||
iD.actions.AddMidpoint({ loc: choice.loc, edge: [d.nodes[choice.index - 1], d.nodes[choice.index]] }, entity),
|
||||
connectAnnotation(d));
|
||||
|
||||
@@ -43,12 +43,8 @@ iD.modes.Move = function(context, entityIDs) {
|
||||
nudgeInterval = null;
|
||||
}
|
||||
|
||||
function point() {
|
||||
return d3.mouse(context.map().surface.node());
|
||||
}
|
||||
|
||||
function move() {
|
||||
var p = point();
|
||||
var p = context.mouse();
|
||||
|
||||
var delta = origin ?
|
||||
[p[0] - context.projection(origin)[0],
|
||||
|
||||
@@ -19,13 +19,9 @@ iD.modes.RotateWay = function(context, wayId) {
|
||||
iD.actions.Noop(),
|
||||
annotation);
|
||||
|
||||
function point() {
|
||||
return d3.mouse(context.map().surface.node());
|
||||
}
|
||||
|
||||
function rotate() {
|
||||
|
||||
var mousePoint = point(),
|
||||
var mousePoint = context.mouse(),
|
||||
newAngle = Math.atan2(mousePoint[1] - pivot[1], mousePoint[0] - pivot[0]);
|
||||
|
||||
if (typeof angle === 'undefined') angle = newAngle;
|
||||
|
||||
@@ -31,7 +31,7 @@ iD.modes.Select = function(context, selection) {
|
||||
if (entity && entity.type === 'node') {
|
||||
radialMenu.center(context.projection(entity.loc));
|
||||
} else {
|
||||
radialMenu.center(context.map().mousePosition());
|
||||
radialMenu.center(context.mouse());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +131,7 @@ iD.modes.Select = function(context, selection) {
|
||||
datum = target.datum();
|
||||
|
||||
if (datum instanceof iD.Way && !target.classed('fill')) {
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(datum),
|
||||
d3.mouse(context.surface().node()), context.projection),
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(datum), context.mouse(), context.projection),
|
||||
node = iD.Node();
|
||||
|
||||
var prev = datum.nodes[choice.index - 1],
|
||||
|
||||
@@ -246,14 +246,14 @@ iD.Map = function(context) {
|
||||
return [l[0] * scale + translate[0], l[1] * scale + translate[1]];
|
||||
}
|
||||
|
||||
map.mousePosition = function() {
|
||||
map.mouse = function() {
|
||||
var e = d3.event, s;
|
||||
while (s = e.sourceEvent) e = s;
|
||||
return mouse(e);
|
||||
};
|
||||
|
||||
map.mouseCoordinates = function() {
|
||||
return projection.invert(map.mousePosition());
|
||||
return projection.invert(map.mouse());
|
||||
};
|
||||
|
||||
map.dblclickEnable = function(_) {
|
||||
|
||||
@@ -236,10 +236,7 @@ iD.svg.Labels = function(projection, context) {
|
||||
|
||||
|
||||
function hideOnMouseover() {
|
||||
|
||||
if (!mousePosition) return;
|
||||
|
||||
var mouse = mousePosition(d3.event),
|
||||
var mouse = context.mouse(),
|
||||
pad = 50,
|
||||
rect = new RTree.Rectangle(mouse[0] - pad, mouse[1] - pad, 2*pad, 2*pad),
|
||||
labels = _.pluck(rtree.search(rect, this), 'leaf'),
|
||||
@@ -273,16 +270,10 @@ iD.svg.Labels = function(projection, context) {
|
||||
|
||||
var rtree = new RTree(),
|
||||
rectangles = {},
|
||||
lang = 'name:' + iD.detect().locale.toLowerCase().split('-')[0],
|
||||
mousePosition, cacheDimensions;
|
||||
lang = 'name:' + iD.detect().locale.toLowerCase().split('-')[0];
|
||||
|
||||
function labels(surface, graph, entities, filter, dimensions, fullRedraw) {
|
||||
|
||||
if (!mousePosition || dimensions.join(',') !== cacheDimensions) {
|
||||
mousePosition = iD.util.fastMouse(surface.node().parentNode);
|
||||
cacheDimensions = dimensions.join(',');
|
||||
}
|
||||
|
||||
var hidePoints = !surface.select('.node.point').node();
|
||||
|
||||
var labelable = [], i, k, entity;
|
||||
|
||||
Reference in New Issue
Block a user