-
Notifications
You must be signed in to change notification settings - Fork 82
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
Dragging the map selects a region #47
Comments
Thank you for reporting this bug! I've just fixed the issue and released a new version please make sure to update to v1.3.3 As for dragging, unfortunately, there is no event fired when dragging the map. However as a workaround you can do the following: const jvm = new jsVectorMap({
selector: "#map",
map: "world_merc",
regionsSelectable: true,
onLoaded(map) {
const container = map.container
// When dragging the map from anywhere inside the container, even if it is not a region.
// container.on('mousedown', () => {
// console.log('Dragging!!')
// })
// .on('mouseup', () => {
// console.log('Released!!')
// })
// OR -> when dragging the region/s itself.
// Using built-in delegate method is recommended because
// all event listeners wrapped within it are removed automatically when the map is destroyed.
container.delegate(".jvm-region", "mousedown mouseup", (event) => {
if (event.type === "mousedown") {
console.log("Region is being dragged!!")
} else {
console.log("Region released!!")
}
})
}
}) Demo: https://codepen.io/themustafaomar/pen/VwWagKV Regards. |
Amazing, thank you so much for your fast response and help!! I really appreciate it! |
So I just tested the fix, and it fixes it a little too well! 😅 I use a trackpad and if I accidentally drag by like a pixel when trying to select a region, it no longer does it. I think this might also be an issue on touch devices although I haven't tried it yet. Is there way to add (or set) a threshold for dragging vs selecting action when both these options are enabled? Like if it drags more than, say, 10 or 20 pixels probably it's intentional, but under that might just be a sloppy click. |
Sorry for the very late response. Although this isn't considered a big issue, I mean it's very difficult to move the cursor 1px or even 5px and very rare condition, but I'll see what I can do. |
That’s what I’m saying - it happens on accident, and usually with a
trackpad or touch device. :) some kind of threshold that I could define to
understand motion as accidental or intentional would be amazing.
Also, please don’t apologize. It’s okay!! I know how open source goes and I
appreciate that you’re maintaining it at all. ❤️
Thank you!!
…On Thu, Sep 30 2021 at 7:56 PM (GMT+3), ***@***.*** wrote:
Sorry for the very late response.
Although this isn't considered a big issue, I mean it's very difficult to
move the cursor 1px or even 5px and very rare condition, but I'll see what
I can do.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#47 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACFXYKESLEY5OVG5MZW6ZF3UESJEXANCNFSM5DGPMMBQ>
.
|
Thank you for the kind words! It'll be fixed it as soon as possible. |
Thank you! |
Hi!
I am very grateful for this plugin, it's saved me a TON of time. I've just noticed a bug while I'm testing my map; if you click and drag the map with the mouse over a region, it selects the region.
Is there any way to disable or modify this behavior, besides disabling dragging? Is there an onDrag event or something? (Also asking because I'd like to change the cursor when it's dragging.)
Thank you!
Crystal
The text was updated successfully, but these errors were encountered: