-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Prevent map tile images from dragging. #1821
Comments
Same problem happen with ImageOverlay in chrome, without ExtJS. I resolved the problem using the solution above (-webkit-user-drag: none;} |
@jfirebaugh take a look please |
@ZeusTheTrueGod or @MatMatic, can you please make a JSFiddle that demonstrates the problem? |
Hi, jsfiddle with Leaflet 0.5.1 (image doesn't drag, map pan on mousedown/mousemove): http://jsfiddle.net/MatMatic/pPDLp/ Same example with Leaflet 0.6.2 (image drag, can't pan map): I know it's kind of weird to have such an image like this in a map, but hey, it's just an example ! ;) I experimented the problem with an imageoverlay containing an image issued by a wms server (yeah, I know, there is class TileLayer.WMS). Thx |
@MatMatic Those fiddles are mix-and-matching 0.4.4 and 0.6.2 JS and CSS, and I'm having a hard time sorting out what's supposed to work and what isn't. Can you please try again with 0.5.1 and 0.6.2, without any script tags in the JSFiddle body -- use the JSFiddle script pane for setup code and "External Resources" for Leaflet CSS/JS. Thanks. |
I cleaned everything. |
@jfirebaugh yep, also reproducible on /debug/map/image-overlay.html |
@ZeusTheTrueGod your use case is not reproducible though, are you sure you updated your CSS files to new version as well? |
I have not setup the example, I am using a leaflet-rails plugin with a latest version. On Jul 4, 2013, at 12:57 PM, Vladimir Agafonkin [email protected] wrote:
|
-webkit-user-drag is not inherited, so it's ineffective at preventing drags of image overlays (#1821). Instead, always preventDefault on dragstart. While here, preventDefault on selectstart as well (a "belt-and-suspenders" approach). Together, these changes bring Leaflet's strategy in line with D3's: https://github.com/mbostock/d3/blob/master/src/event/drag.js
Fixed in a1d7c12. |
Thanks, I'll try this version. |
Shouldn't |
Yes, building it right now |
Same problem. And agree that if dist is in the repo, it should remain consistent with the rest of the code. |
Just to make sure I understand this thread: So a1d7c12 fixes this issue (you're trying to pan the map, and you wind up dragging tiles around instead). I can download a1d7c12, but I'll have to build it, because the dist folder still contains the compilation of the base version (0.6.2). Did I get all that right? Thanks. Aaron |
@FunkMonkey33 Check the download page http://leafletjs.com/download.html |
Hi guys, I wanted to check in on this issue as I'm seeing it happen with Leaflet.js 0.6.4 (via the CDN) in Firefox 24.0. I didn't write the original code we're using but before I dig in was curious to know if this is a known issue. |
This issue shouldn't happen in the current release of leaflet. |
Thanks for the heads up. I'll take a look on Monday when I'm back in the office and look into what might be causing it. |
@danzel We tested this today and it appears to be happening when dragging is set to disabled Again, I'm not sure if this is expected behavior and would love to know what you guys think. |
Yes you are right! |
Have spent a bit of time taking a look. If you disable dragging, the js to stop image dragging isn't set up (Map.Drag isn't set up). .leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
-webkit-user-drag: none;
} Firefox has no equivalent attribute. It looks like markers always set up preventDefault, so the issue doesn't happen with them. @jfirebaugh - Thoughts? |
I guess I wouldn't necessarily consider it a bug that the browser default drag behavior prevails if you disable Leaflet's own drag behavior. If we don't want that to be the case, we need to arrange for |
Lets close this and create a separate issue if necessary. I'm also not sure if this should be considered a bug if dragging is disabled. |
@jfirebaugh thanks for chiming in btw! |
Thanks for the help with this btw. This is a great library :) |
Has this issue been resurrected anywhere? I am seeking a fix for this specific firefox behavior. |
strike that this seems to be fixed in 0.7.* |
jfirebaugh L.DomUtil.disableImageDrag() works like a charm, thank you ! LOL |
I use leaflet inside an ExtJS app. I test in Chrome. I use Mac OS X, Retina display. The openstreetmaps layer images are draggable, i.e. I drag the tile img which looks weird.
This css style solves the issue: {
-webkit-user-drag: none;
user-drag: none;
}
Leaflet already uses -webkit-user-select: none. It is enough in most cases, but looks like not always.
I'll try to set up a jsfiddle example but whatever I think this extra css will not make things worse. At least that is what I use as a workaround in my current project.
The text was updated successfully, but these errors were encountered: