CSS-based outline prevention
This commit is contained in:
parent
63753d8564
commit
a865d2b649
@ -219,4 +219,19 @@ L.DomUtil = {
|
||||
L.DomUtil.enableImageDrag = function () {
|
||||
L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);
|
||||
};
|
||||
|
||||
L.DomUtil.preventOutline = function (element) {
|
||||
L.DomUtil.restoreOutline();
|
||||
this._outlineElement = element;
|
||||
this._outlineStyle = element.style.outline;
|
||||
element.style.outline = 'none';
|
||||
L.DomEvent.on(window, 'keydown', L.DomUtil.restoreOutline, this);
|
||||
};
|
||||
L.DomUtil.restoreOutline = function () {
|
||||
if (!this._outlineElement) { return; }
|
||||
this._outlineElement.style.outline = this._outlineStyle;
|
||||
delete this._outlineElement;
|
||||
delete this._outlineStyle;
|
||||
L.DomEvent.off(window, 'keydown', L.DomUtil.restoreOutline, this);
|
||||
};
|
||||
})();
|
||||
|
@ -51,7 +51,7 @@ L.Draggable = L.Evented.extend({
|
||||
L.DomEvent.stopPropagation(e);
|
||||
|
||||
if (this._preventOutline) {
|
||||
L.DomEvent.preventDefault(e);
|
||||
L.DomUtil.preventOutline(this._element);
|
||||
}
|
||||
|
||||
if (L.DomUtil.hasClass(this._element, 'leaflet-zoom-anim')) { return; }
|
||||
|
@ -581,8 +581,8 @@ L.Map = L.Evented.extend({
|
||||
!L.DomEvent._checkMouse(this._container, e)) { return; }
|
||||
|
||||
// prevents outline when clicking on keyboard-focusable element
|
||||
if (target && type === 'mousedown') {
|
||||
L.DomEvent.preventDefault(e);
|
||||
if (type === 'mousedown') {
|
||||
L.DomUtil.preventOutline(e.target || e.srcElement);
|
||||
}
|
||||
|
||||
this._fireDOMEvent(target || this, e, type);
|
||||
|
Loading…
Reference in New Issue
Block a user