hotfix: fix move tool left click behaviour
This commit is contained in:
12
app.js
12
app.js
@@ -35,8 +35,10 @@ let isPanning = false;
|
|||||||
let panStart = null;
|
let panStart = null;
|
||||||
|
|
||||||
map.getContainer().addEventListener('mousedown', (e) => {
|
map.getContainer().addEventListener('mousedown', (e) => {
|
||||||
// Middle mouse button OR right-click in select mode
|
// Middle mouse button OR right-click in select/move mode OR left-click in move mode
|
||||||
if (e.button === 1 || (e.button === 2 && currentTool === 'select')) {
|
if (e.button === 1 ||
|
||||||
|
(e.button === 2 && (currentTool === 'select' || currentTool === 'move')) ||
|
||||||
|
(e.button === 0 && currentTool === 'move')) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
isPanning = true;
|
isPanning = true;
|
||||||
panStart = { x: e.clientX, y: e.clientY };
|
panStart = { x: e.clientX, y: e.clientY };
|
||||||
@@ -64,7 +66,7 @@ map.getContainer().addEventListener('mousemove', (e) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
map.getContainer().addEventListener('mouseup', (e) => {
|
map.getContainer().addEventListener('mouseup', (e) => {
|
||||||
if (e.button === 1 || e.button === 2) {
|
if (e.button === 1 || e.button === 2 || e.button === 0) {
|
||||||
isPanning = false;
|
isPanning = false;
|
||||||
panStart = null;
|
panStart = null;
|
||||||
map.getContainer().style.cursor = '';
|
map.getContainer().style.cursor = '';
|
||||||
@@ -226,8 +228,8 @@ map.on('contextmenu', (e) => {
|
|||||||
L.DomEvent.preventDefault(e);
|
L.DomEvent.preventDefault(e);
|
||||||
const latlng = e.latlng;
|
const latlng = e.latlng;
|
||||||
|
|
||||||
if (currentTool === 'select') {
|
if (currentTool === 'select' || currentTool === 'move') {
|
||||||
// Allow map panning with right-click in select mode
|
// Allow map panning with right-click in select and move mode
|
||||||
return;
|
return;
|
||||||
} else if (currentTool === 'line') {
|
} else if (currentTool === 'line') {
|
||||||
if (drawingLine) {
|
if (drawingLine) {
|
||||||
|
|||||||
Reference in New Issue
Block a user