Fork me on GitHub
#reagent
<
2020-08-10
>
Casey11:08:49

Is there a straightforward way to get a reference to the dom element of a component inside an event handler? It's dirty I know... I have a component wrapping an <svg> and am implementing pan and zoom events on the svg. Mouse events performed on children of the svg (such as shapes in the image) have a e.target value of the child, not the parent svg element. But I need a handle on the svg dom element to call getBoundingClientRect()

selfsame13:08:27

@ramblurr e.target.parentElement

Casey14:08:27

@selfsame that assumes the target is a direct descendent of the svg, which it often isn't. I suppose I could just walk up the elements until landing on svg, but I figure there might be a cleaner way

selfsame14:08:06

ah then you'll have to walk the tree or use a :ref