0

How can be determined a point's situation relative to element ( inside or outside ) by javascript? elementFromPoint() return topmost element.Can be find bottom element?

 <svg width="500" height="300" >

        <polygon points="200,10 250,190 160,210" style="fill:white;stroke:black" />
</svg>

Html code is just an example.Vertexs may be much more.One possible solution could be trigger an event from point and get the event's target.Is there any ready Javascript method to trigger event from point?Another sugesstion is appriciated too.

Mehmet
  • 739
  • 1
  • 6
  • 17
  • Possible duplicate of [How to determine if a point is in a 2D triangle?](http://stackoverflow.com/questions/2049582/how-to-determine-if-a-point-is-in-a-2d-triangle) – Niklesh Raut Apr 04 '17 at 09:36
  • My requirement is not limited triangle.Vertex can be much more.I try to find a way trigger onclick event at any point and get element of that event.Is it possible to success via a ready javascript method? – Mehmet Apr 04 '17 at 10:52
  • Possible duplicate of [Is point inside polygon?](http://stackoverflow.com/questions/39853481/is-point-inside-polygon) – Bartek Banachewicz Apr 04 '17 at 11:41

1 Answers1

0

I found the solution from element's isPointInFill() method.This method's parameter is SVGPoint. Only Chrome support isPointInFill() at this stage.

Mehmet
  • 739
  • 1
  • 6
  • 17