Created
January 8, 2010 21:52
-
-
Save padolsey/272459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getElementsInRegion(x, y, width, height) { | |
var elements = [], | |
expando = +new Date, | |
cx = x, | |
cy = y, | |
curEl; | |
height = y + height; | |
width = x + width; | |
while ((cy += 5) < height) { | |
cx = x; | |
while (cx < width) { | |
curEl = document.elementFromPoint(cx, cy); | |
if ( curEl && !curEl[expando] ) { | |
curEl[expando] = new Number(0); | |
elements.push(curEl); | |
cx += curEl.offsetWidth; | |
} else { | |
cx += 5; | |
} | |
} | |
} | |
return elements; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment