Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rotation bug #24

Merged
merged 3 commits into from
Jan 29, 2024
Merged

Fix rotation bug #24

merged 3 commits into from
Jan 29, 2024

Conversation

mfbehrens
Copy link
Owner

No description provided.

@mfbehrens mfbehrens added the bug Something isn't working label Jun 27, 2023
Handler cannot be removed when .bind() function is used

Find solution
@mfbehrens mfbehrens marked this pull request as draft June 27, 2023 22:26
@mfbehrens
Copy link
Owner Author

@AnJ95 wäre nice wenn du dir das nochmal anschauen könntest

@AnJ95
Copy link
Collaborator

AnJ95 commented Jun 28, 2023

Habe direkt im Konstruktor die handler gebindet, das ist etwas schöner.

@AnJ95
Copy link
Collaborator

AnJ95 commented Jun 28, 2023

Man kann ein MapItem während es selected ist mit einem Rechtsklick auf das MapItem selbst draggen UND rotieren; das führt zu unerwartetem Verhalten, Issue kann also offen bleiben.

Leider hat leaflet-path-drag keine Option genauer nach event.button zu filtern. Issue?

Habe probiert das draggen irgendwie abzubrechen bzw die events zu verhindern, habs auf Anhieb aber nicht geschafft.

@mfbehrens
Copy link
Owner Author

See w8r/Leaflet.Path.Drag#63

Hacky solution:

// Create a path (e.g., a polyline)
const path = L.polyline([[lat1, lng1], [lat2, lng2], [lat3, lng3]]);

// Add the path to the map
path.addTo(map);

// Register the mousedown event handler on the path
path.on('mousedown', function (event) {
  // Check the mouse button
  if (event.originalEvent.button === 2) {
    // Right mouse button is clicked, prevent dragging
    path.dragging.disable();
  } else {
    // Left mouse button is clicked, allow dragging
    path.dragging.enable();
  }
});

Credits to ChatGPT

@mfbehrens
Copy link
Owner Author

Problem scheint nicht ganz so leicht fixbar zu sein. Objekt wird zuerst gedraggt, dann wird dragging disabled, weshalb noch einmal gedraggt werden kann bis die Verschiebung deaktiviert ist

@mfbehrens mfbehrens marked this pull request as ready for review January 24, 2024 18:06
@mfbehrens mfbehrens merged commit fe8e89f into main Jan 29, 2024
@mfbehrens mfbehrens deleted the fix-rotation branch May 22, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants