Intercepting all events, handling, then letting them to object underneath

空扰寡人 提交于 2019-12-12 04:24:28

问题


I have a page which has an iframe (containing an interactive map) and a canvas positioned over it by z-depth, to draw as if into the map. So neither are a parent of the other, they're just located in the same place. Both the canvas and the map need to be able to handle the same click events: the map (for interaction with it), and the canvas (to set timeouts for map status changes, for selecting objects, etc).

I'm having trouble figuring out how one is supposed to get all events to flow from one to the next. I tried making one a parent of the other (such as putting the map iframe inside the canvas) so it could flow up the DOM, but then the map doesn't draw. I found this code for using a dispatchEvent to forward copies of events:

Is it possible to selectively pass DOM events through overlapping canvases?

But it seems needlessly complicated, would need to be implemented for every event, and more to the point, didn't work when I tried it.

Surely there's something easy I'm missing... thoughts?

来源:https://stackoverflow.com/questions/46841061/intercepting-all-events-handling-then-letting-them-to-object-underneath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!