在传单上覆盖div,并停止鼠标动作的传播

时间:2018-09-13 08:13:15

标签: javascript leaflet

如何停止在div上单击并滚动并覆盖传单地图的行为?这似乎很棘手... 像

customPreventDefault(e) {
    e = e || window.event;
    if (e.preventDefault)
        e.preventDefault();
    e.returnValue = false;
}

document.getElementById('no-scrolling-clicking').onmousewheel =
    function (e) {
        document.getElementById('prevent-scrolling').scrollTop -= e.wheelDeltaY;
        customPreventDefault(e);
    }
}

不做任何事情。它也需要在IE中工作...

http://jsfiddle.net/LnzN2/4888/

1 个答案:

答案 0 :(得分:0)

leaflet为此提供了功能。

  var div = L.DomUtil.get('no-scrolling-clicking');
  L.DomEvent.on(div, 'mousewheel', L.DomEvent.stopPropagation);
  L.DomEvent.on(div, 'click', L.DomEvent.stopPropagation);