Optimise hit-testing by checking point to lie within #roughBounds + tolerance first.

This commit is contained in:
Jürg Lehni 2011-07-08 21:01:34 +02:00
parent fe37ce6bcb
commit 1b3d4773a3

View file

@ -670,6 +670,12 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
hitTest: function(point, options, matrix) {
options = HitResult.getOptions(options);
// Check if the point is withing roughBounds + tolerance, but only if
// this item does not have children, since we'd have to travel up the
// chain already to determine the rough bounds.
if (!this._children && !this.getRoughBounds(matrix)
.expand(options.tolerance).contains(point))
return null;
// TODO: Support option.type even for things like CompoundPath where
// children are matched but the parent is returned.