I have a web page with two canvases sitting on top of one another:
<style>
canvas {
position: absolute;
}
</style>
<canvas id="first" width=800 height=600></canvas>
<canvas id="second" width=800 height=600></canvas>
(Full example here.)
If I register mousedown
handlers for both canvases:
document.getElementById('first').addEventListener('mousedown', function () {
console.log('first canvas mousedown');
});
document.getElementById('second').addEventListener('mousedown', function () {
console.log('second canvas mousedown');
});
and click on them, then I only see second canvas mousedown
logged. This makes sense since it's on top.
I'd like the event handler for the second
canvas to have a first crack at handling the event but, if it doesn't care about it, let it pass through to the event handler for the first
canvas, which is underneath it.
In reality these <canvas>
es are parts of independent React components, so it's not trivial to unify the event handlers.