Skip to content

Instantly share code, notes, and snippets.

@danbeam
Created August 26, 2011 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbeam/1174594 to your computer and use it in GitHub Desktop.
Save danbeam/1174594 to your computer and use it in GitHub Desktop.
// Why aren't we native yet?
ClientRect.prototype.contains = function (x, y) {
// support 1 arg of {x: ##, y: ##}
if (x && x.x && !y) {
y = x.y;
x = x.x;
}
return (x >= this.left && x <= this.right &&
y >= this.top && y <= this.bottom);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment