I am attempting to compare any two elements in the DOM to see if they were to be painted(rendered on screen) in the same area (coordinates overlapping) which one would be above the other. This question is not about overlapping calculation, rather it is about comparing any two elements from any part of the DOM tree for above position (calculating stacking context and z-index and HTML hierarchy...).
Although I am new to this area, my approach would traverse and assign a numerical value to each HTML element taking into consideration rules and standards. Another problem is getting them correctly. I was not able to find a JS library that already does this.
For css and full code example see... https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
The expected output is the ability to compare any two HTML elements for above or below position (3D). I will share my code if I get an idea from professionals here and be able to implement it. Thanks any help is appreciated.