Reputation: 121
What i need is a clickhandler to be able to work on multiple layered objects in an SVG, paths or lines for example. What would be the best approach to determine all the elements that pass through a certain coordinate.
Upvotes: 1
Views: 98
Reputation: 21578
Probably the simplest solution is to use document.elementsFromPoint()
:
The
elementsFromPoint()
property of theDocumentOrShadowRoot
interface returns an array of all elements at the specified coordinates (relative to the viewport).
The browser compatibility is good and it will give you all the elements with a single call.
Upvotes: 1
Reputation: 124129
Upvotes: 2