mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3786 from node-red/fix-quick-add-pos
Properly position quick-add dialog in all cases
This commit is contained in:
commit
d52be76c8a
@ -44,14 +44,10 @@ RED.contextMenu = (function () {
|
|||||||
const canRemoveFromGroup = hasSelection && !!selection.nodes[0].g
|
const canRemoveFromGroup = hasSelection && !!selection.nodes[0].g
|
||||||
const offset = $("#red-ui-workspace-chart").offset()
|
const offset = $("#red-ui-workspace-chart").offset()
|
||||||
|
|
||||||
let addX = options.x - offset.left + $("#red-ui-workspace-chart").scrollLeft()
|
// addX/addY must be the position in the workspace accounting for both scroll and scale
|
||||||
let addY = options.y - offset.top + $("#red-ui-workspace-chart").scrollTop()
|
// The +5 is because we display the contextMenu -5,-5 to actual click position
|
||||||
|
let addX = (options.x + 5 - offset.left + $("#red-ui-workspace-chart").scrollLeft()) / RED.view.scale()
|
||||||
if (RED.view.snapGrid) {
|
let addY = (options.y + 5 - offset.top + $("#red-ui-workspace-chart").scrollTop()) / RED.view.scale()
|
||||||
const gridSize = RED.view.gridSize()
|
|
||||||
addX = gridSize * Math.floor(addX / gridSize)
|
|
||||||
addY = gridSize * Math.floor(addY / gridSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{ onselect: 'core:show-action-list', onpostselect: function () { } },
|
{ onselect: 'core:show-action-list', onpostselect: function () { } },
|
||||||
|
@ -1071,12 +1071,15 @@ RED.view = (function() {
|
|||||||
RED.view.redraw();
|
RED.view.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `point` is the place in the workspace the mouse has clicked.
|
||||||
|
// This takes into account scrolling and scaling of the workspace.
|
||||||
var ox = point[0];
|
var ox = point[0];
|
||||||
var oy = point[1];
|
var oy = point[1];
|
||||||
|
|
||||||
|
// Need to map that to browser location to position the pop-up
|
||||||
const offset = $("#red-ui-workspace-chart").offset()
|
const offset = $("#red-ui-workspace-chart").offset()
|
||||||
var clientX = ox + offset.left - $("#red-ui-workspace-chart").scrollLeft()
|
var clientX = (ox * scaleFactor) + offset.left - $("#red-ui-workspace-chart").scrollLeft()
|
||||||
var clientY = oy + offset.top - $("#red-ui-workspace-chart").scrollTop()
|
var clientY = (oy * scaleFactor) + offset.top - $("#red-ui-workspace-chart").scrollTop()
|
||||||
|
|
||||||
if (RED.settings.get("editor").view['view-snap-grid']) {
|
if (RED.settings.get("editor").view['view-snap-grid']) {
|
||||||
// eventLayer.append("circle").attr("cx",point[0]).attr("cy",point[1]).attr("r","2").attr('fill','red')
|
// eventLayer.append("circle").attr("cx",point[0]).attr("cy",point[1]).attr("r","2").attr('fill','red')
|
||||||
|
Loading…
Reference in New Issue
Block a user