Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
Add findElementAt method to domElement
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelerz committed Jun 3, 2015
1 parent ff7970d commit b708c55
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion lib/configuration/structure/domElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,41 @@ var DomElement = Base.extend(
} else {
return result;
}
},

/**
* Finds a DOM-element at an absolute coordinate
*
* @method findElementAt
* @param {int} x X-coordinate
* @param {int} y Y-coordinate
*/
findElementAt: function (x, y) {

var nodes,
result,
i;

if (this.getRect().inBounds(x, y)) {
return this;

} else {
nodes = this.getNodes();

if (nodes) {

// Travers from the back so that overlapping elements will be selected first
for (i = nodes.length; i >= 0; i--) {
result = nodes[i].findElementAt(x, y);

if (result) {
return result;
}
}
}

return null;
}
}
},

Expand All @@ -227,6 +262,6 @@ var DomElement = Base.extend(
* @type {string}
* @static
*/
TYPE: 'CONFIGURATION_STRUCTURE_DOMELEMENT'
TYPE: 'CONFIGURATION_STRUCTURE_DOM_ELEMENT'
}
);

0 comments on commit b708c55

Please sign in to comment.