Skip to content

Commit 0a01587

Browse files
committed
Layer DOM rearrangement fix
1 parent 0d0538a commit 0a01587

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/layer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ export class MapLayer extends HTMLElement {
237237
for (var nodes = this.parentNode.children;i < nodes.length;i++) {
238238
if (this.parentNode.children[i].nodeName === "LAYER-") {
239239
if (this.parentNode.children[i] === this) {
240-
break;
240+
position = i + 1;
241+
} else if (this.parentNode.children[i]._layer) {
242+
this.parentNode.children[i]._layer.setZIndex(i+1);
241243
}
242-
position++;
243244
}
244245
}
245246
var proj = this.parentNode.projection ? this.parentNode.projection : "OSMTILE";

src/mapml/layers/MapLayer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,10 @@ export var MapMLLayer = L.Layer.extend({
545545

546546
// Fixes flickering by only moving element when there is enough space
547547
let offset = e.offsetY < 0 ? Math.abs(e.offsetY*2) : Math.abs(e.offsetY);
548-
if(offset <= swapControl.offsetHeight){
549-
swapControl = control;
550-
}
548+
swapControl = offset <= swapControl.offsetHeight ? control : swapControl;
551549

552550
control.style.opacity = "0";
551+
control.classList.add("leaflet-dragging");
553552
control.setAttribute("aria-grabbed", 'true');
554553
control.setAttribute("aria-dropeffect", "move");
555554
if(swapControl && controls === swapControl.parentNode){
@@ -560,6 +559,7 @@ export var MapMLLayer = L.Layer.extend({
560559
fieldset.ondragend = (e) => {
561560
e.preventDefault();
562561
e.target.style.opacity = null;
562+
e.target.classList.remove("leaflet-dragging");
563563
e.target.setAttribute("aria-grabbed", "false");
564564
e.target.removeAttribute("aria-dropeffect");
565565
let controls = e.target.parentNode.children,

0 commit comments

Comments
 (0)