mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-15 01:09:53 -04:00
Optimise hit-testing by checking point to lie within #roughBounds + tolerance first.
This commit is contained in:
parent
fe37ce6bcb
commit
1b3d4773a3
1 changed files with 6 additions and 0 deletions
|
@ -670,6 +670,12 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
|
||||||
|
|
||||||
hitTest: function(point, options, matrix) {
|
hitTest: function(point, options, matrix) {
|
||||||
options = HitResult.getOptions(options);
|
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
|
// TODO: Support option.type even for things like CompoundPath where
|
||||||
// children are matched but the parent is returned.
|
// children are matched but the parent is returned.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue