javascript - 将 div 覆盖在传单上并停止鼠标操作传播

标签 javascript leaflet

如何停止在 div 上单击和滚动并覆盖传单 map 的传播?这似乎很棘手...... 有点像

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/

最佳答案

parent-div 移到 map div 之外。

将您的 HTML 更改为:

<div 
  id="map">

</div>
<div 
  id='parent-div'
  class='some-div'>
   I am the parent! Like the leaflet map, I don't want the mouse events clicking/scrolling bubbling onto me neither.
    <div 
      class='some-div'
      id='no-scrolling-clicking'>
      Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me! Stop Scrolling and clicking Event in me!
    </div>
  </div>

关于javascript - 将 div 覆盖在传单上并停止鼠标操作传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52309356/

相关文章:

javascript - 从 Objective-C 代码调用 javascript

leaflet - 错误类型错误 : Cannot read property '_leaflet_pos' of undefined

javascript - map 中浏览器的最大 svg 元素数

javascript - Proj4Leaflet 自定义投影原点

javascript - dijit.tree 如何仅使用存储来实现折叠所有功能?

javascript - 执行前延迟

javascript - 如何以编程方式打开传单标记的工具提示?

leaflet - 如何将 Leaflet 集成到 Angular 5 中

javascript - 如何防止 Backbone 和 Node.js/Hapi 出现 CORB 错误?

javascript - 检测元素的特定 CSS 动画的结束