0

I'm building a visual editing tool in the browser.

In my tool, the user can draw a random line between any 2 points on the page.

Point A could be at 0px, 100px. Point B could be at 50px, 200px.

I want to find all DOM elements that are intersected by that line.

What's the best way to do this?

For example:

var elements = queryByLine(0, 10, 50, 200) // x1, y1, x2, y1

Expected (an array of dom elements):

$(elements).addClass('intersected')

Breck
  • 670
  • 2
  • 7
  • 22

0 Answers0