mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Perform point conversion along with HitResult.getOptions().
This commit is contained in:
parent
cc00f40532
commit
9db96ae898
3 changed files with 8 additions and 3 deletions
|
@ -36,9 +36,12 @@ HitResult = Base.extend(/** @lends HitResult# */{
|
|||
*
|
||||
* @private
|
||||
*/
|
||||
getOptions: function(options) {
|
||||
getOptions: function(point, options) {
|
||||
// TODO: Consier moving to HitResult / HitEvent?
|
||||
return options && options._merged ? options : Base.merge({
|
||||
// Use the converted options object to perform point conversion
|
||||
// only once.
|
||||
point: Point.read(arguments, 0, 1),
|
||||
// Type of item, for instanceof check: PathItem, TexItem, etc
|
||||
type: Item,
|
||||
// Tolerance
|
||||
|
|
|
@ -669,7 +669,8 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
|
|||
},
|
||||
|
||||
hitTest: function(point, options, matrix) {
|
||||
options = HitResult.getOptions(options);
|
||||
options = HitResult.getOptions(point, options);
|
||||
point = options.point;
|
||||
// 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.
|
||||
|
|
|
@ -182,7 +182,8 @@ var Project = this.Project = Base.extend(/** @lends Project# */{
|
|||
},
|
||||
|
||||
hitTest: function(point, options) {
|
||||
options = HitResult.getOptions(options);
|
||||
options = HitResult.getOptions(point, options);
|
||||
point = options.point;
|
||||
// Loop backwards, so layers that get drawn last are tested first
|
||||
for (var i = this.layers.length - 1; i >= 0; i--) {
|
||||
var res = this.layers[i].hitTest(point, options);
|
||||
|
|
Loading…
Reference in a new issue