mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Always show the edit menu at the location of the triggering event
This commit is contained in:
@@ -159,11 +159,11 @@ export function behaviorSelect(context) {
|
||||
var datum = (d3_event && d3_event.target.__data__) || (_lastPointerEvent && _lastPointerEvent.target.__data__);
|
||||
var isMultiselect = (d3_event && d3_event.shiftKey) || context.surface().select('.lasso').node();
|
||||
|
||||
processClick(datum, isMultiselect);
|
||||
processClick(datum, isMultiselect, p2);
|
||||
}
|
||||
|
||||
|
||||
function processClick(datum, isMultiselect) {
|
||||
function processClick(datum, isMultiselect, point) {
|
||||
var mode = context.mode();
|
||||
|
||||
var entity = datum && datum.properties && datum.properties.entity;
|
||||
@@ -183,14 +183,14 @@ export function behaviorSelect(context) {
|
||||
if (!isMultiselect) {
|
||||
if (selectedIDs.length > 1 && (_showMenu && !_alwaysShowMenu)) {
|
||||
// multiple things already selected, just show the menu...
|
||||
mode.reselect().showMenu(_lastInteractionType);
|
||||
mode.reselect().showMenu(point, _lastInteractionType);
|
||||
} else {
|
||||
// always enter modeSelect even if the entity is already
|
||||
// selected since listeners may expect `context.enter` events,
|
||||
// e.g. in the walkthrough
|
||||
newMode = modeSelect(context, [datum.id]);
|
||||
context.enter(newMode);
|
||||
if (_showMenu) newMode.showMenu(_lastInteractionType);
|
||||
if (_showMenu) newMode.showMenu(point, _lastInteractionType);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -198,7 +198,7 @@ export function behaviorSelect(context) {
|
||||
// clicked entity is already in the selectedIDs list..
|
||||
if (_showMenu && !_alwaysShowMenu) {
|
||||
// don't deselect clicked entity, just show the menu.
|
||||
mode.reselect().showMenu(_lastInteractionType);
|
||||
mode.reselect().showMenu(point, _lastInteractionType);
|
||||
} else {
|
||||
// deselect clicked entity, then reenter select mode or return to browse mode..
|
||||
selectedIDs = selectedIDs.filter(function(id) { return id !== datum.id; });
|
||||
@@ -210,7 +210,7 @@ export function behaviorSelect(context) {
|
||||
selectedIDs = selectedIDs.concat([datum.id]);
|
||||
newMode = modeSelect(context, selectedIDs);
|
||||
context.enter(newMode);
|
||||
if (_showMenu) newMode.showMenu(_lastInteractionType);
|
||||
if (_showMenu) newMode.showMenu(point, _lastInteractionType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { behaviorLasso } from '../behavior/lasso';
|
||||
import { behaviorPaste } from '../behavior/paste';
|
||||
import { behaviorSelect } from '../behavior/select';
|
||||
|
||||
import { geoExtent, geoChooseEdge, geoPointInPolygon } from '../geo';
|
||||
import { geoExtent, geoChooseEdge } from '../geo';
|
||||
import { modeBrowse } from './browse';
|
||||
import { modeDragNode } from './drag_node';
|
||||
import { modeDragNote } from './drag_note';
|
||||
@@ -147,7 +147,7 @@ export function modeSelect(context, selectedIDs) {
|
||||
.select('.edit-menu').remove();
|
||||
}
|
||||
|
||||
mode.showMenu = function(triggerType) {
|
||||
mode.showMenu = function(anchorPoint, triggerType) {
|
||||
|
||||
// remove any displayed menu
|
||||
closeMenu();
|
||||
@@ -160,11 +160,6 @@ export function modeSelect(context, selectedIDs) {
|
||||
return context.graph().geometry(id) === 'relation';
|
||||
})) return;
|
||||
|
||||
var point = context.map().mouse();
|
||||
var viewport = geoExtent(context.projection.clipExtent()).polygon();
|
||||
// make sure a vaild position can be determined
|
||||
if (!point || !geoPointInPolygon(point, viewport)) return;
|
||||
|
||||
var surfaceNode = context.surface().node();
|
||||
if (surfaceNode.focus) { // FF doesn't support it
|
||||
// focus the surface or else clicking off the menu may not trigger modeBrowse
|
||||
@@ -175,7 +170,7 @@ export function modeSelect(context, selectedIDs) {
|
||||
if (!_editMenu) _editMenu = uiEditMenu(context);
|
||||
|
||||
_editMenu
|
||||
.anchorLoc(point)
|
||||
.anchorLoc(anchorPoint)
|
||||
.triggerType(triggerType)
|
||||
.operations(operations);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user