mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
parent
c9a8d54623
commit
aec1c2c138
2 changed files with 24 additions and 0 deletions
|
@ -121,7 +121,16 @@ var SymbolItem = Item.extend(/** @lends SymbolItem# */{
|
|||
},
|
||||
|
||||
_hitTestSelf: function(point, options, viewMatrix) {
|
||||
// We need to call definition item hit test with `options.all`
|
||||
// disabled, otherwise it would populate the array with its own
|
||||
// matches. What we want instead is only returning one match per symbol
|
||||
// item (#1680). So we store original matches array...
|
||||
var all = options.all;
|
||||
// ...we temporarily disable `options.all`...
|
||||
delete options.all;
|
||||
var res = this._definition._item._hitTest(point, options, viewMatrix);
|
||||
// ...then after hit testing, we restore the original matches array.
|
||||
options.all = all;
|
||||
// TODO: When the symbol's definition is a path, should hitResult
|
||||
// contain information like HitResult#curve?
|
||||
if (res)
|
||||
|
|
|
@ -143,3 +143,18 @@ test('SymbolItem#bounds with #applyMatrix = false', function() {
|
|||
equals(function() { return placed.bounds; },
|
||||
{ x: 150, y: 150, width: 100, height: 100 });
|
||||
});
|
||||
|
||||
test('SymbolItem#hitTestAll', function() {
|
||||
var symbol = new SymbolDefinition(
|
||||
new Path.Circle({
|
||||
center: [0, 0],
|
||||
radius: 10,
|
||||
fillColor: 'orange'
|
||||
})
|
||||
);
|
||||
var symbolItem = symbol.place([50, 50]);
|
||||
|
||||
var hitTestAll = symbolItem.hitTestAll([50, 50]);
|
||||
equals(hitTestAll.length, 1);
|
||||
equals(hitTestAll[0].item.id, symbolItem.id);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue