prevent focus outline when dragging objects

This commit is contained in:
Vladimir Agafonkin 2014-11-18 20:27:52 +02:00
parent 0a68b25ce5
commit 63753d8564
3 changed files with 8 additions and 3 deletions

View File

@ -20,9 +20,10 @@ L.Draggable = L.Evented.extend({
}
},
initialize: function (element, dragStartTarget) {
initialize: function (element, dragStartTarget, preventOutline) {
this._element = element;
this._dragStartTarget = dragStartTarget || element;
this._preventOutline = preventOutline;
},
enable: function () {
@ -49,6 +50,10 @@ L.Draggable = L.Evented.extend({
L.DomEvent.stopPropagation(e);
if (this._preventOutline) {
L.DomEvent.preventDefault(e);
}
if (L.DomUtil.hasClass(this._element, 'leaflet-zoom-anim')) { return; }
L.DomUtil.disableImageDrag();

View File

@ -11,7 +11,7 @@ L.Handler.MarkerDrag = L.Handler.extend({
var icon = this._marker._icon;
if (!this._draggable) {
this._draggable = new L.Draggable(icon, icon);
this._draggable = new L.Draggable(icon, icon, true);
}
this._draggable.on({

View File

@ -581,7 +581,7 @@ L.Map = L.Evented.extend({
!L.DomEvent._checkMouse(this._container, e)) { return; }
// prevents outline when clicking on keyboard-focusable element
if (type === 'mousedown') {
if (target && type === 'mousedown') {
L.DomEvent.preventDefault(e);
}