Is It Possible To Selectively Pass DOM Events Through Overlapping Canvases? August 25, 2022 Post a Comment I have a web page with two canvases sitting on top of one another: Solution 1: It's possible (albeit tedious) to recreate a new event object that mirrors the contents of the first, and then dispatch to the other element, e.g.: var pass = false; // toggles on each event first.addEventListener('mousedown', function(e) { output.innerHTML = "first"; }); second.addEventListener('mousedown', function(e) { pass = !pass; if (pass) { var fields = ['screenX', 'screenY', 'clientX', 'clientY', 'ctrlKey', 'altKey', 'shiftKey', 'metaKey', 'button', 'buttons', 'relatedTarget', 'region']; var opts = {}; fields.forEach(function(f) { if (f in e) { opts[f] = e[f]; } }); var copy = new MouseEvent(e.type, opts); first.dispatchEvent(copy); } else { output.innerHTML = "second"; } }); Copy There are other properties from the MouseEvent's super-interfaces that you might want to copy too. demo at https://jsfiddle.net/070ckbra/2/Baca JugaNo Page Rendering While Img Onload-event In JavascriptCustomevent() To An Xul Tab - Firefox AddonWhy The Subtle Cross-browser Differences In Event Object Share You may like these postsHow To Get Sum Of List Value And After Unselect Value Shoud Substract In React NativeHide/unhide Actions Icons Based On State.vallue Value ReactjsReact : Rendering A Syntax Highlighted Code BlockGet Value From Textinput And Pass To Grandparent And To The Child React Native Post a Comment for "Is It Possible To Selectively Pass DOM Events Through Overlapping Canvases?"
Post a Comment for "Is It Possible To Selectively Pass DOM Events Through Overlapping Canvases?"