mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Switch from options.type to options.class in Item#hitTest(), to reflect recent change in Item#getItems().
This commit is contained in:
parent
a931a2530c
commit
397c81e060
3 changed files with 15 additions and 16 deletions
|
@ -1657,9 +1657,9 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
* <b>options.tolerance:</b> {@code Number} – the tolerance of the hit test
|
||||
* in points. Can also be controlled through
|
||||
* {@link Project#options}{@code .hitTolerance}.
|
||||
* <b>options.type:</b> Only hit test again a certain item type:
|
||||
* {@code Group, Layer, Path, CompoundPath, Shape, Raster, PlacedSymbol,
|
||||
* PointText}, etc.
|
||||
* <b>options.class:</b> Only hit test again a certain item class and its
|
||||
* sub-classes: {@code Group, Layer, Path, CompoundPath, Shape, Raster,
|
||||
* PlacedSymbol, PointText}, etc.
|
||||
* <b>options.fill:</b> {@code Boolean} – hit test the fill of items.
|
||||
* <b>options.stroke:</b> {@code Boolean} – hit test the stroke of path
|
||||
* items, taking into account the setting of stroke color and width.
|
||||
|
@ -1722,14 +1722,12 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
.expand(tolerancePadding.multiply(2))._containsPoint(point))
|
||||
return null;
|
||||
// Filter for type, guides and selected items if that's required.
|
||||
var type,
|
||||
checkSelf = !(options.guides && !this._guide
|
||||
var checkSelf = !(options.guides && !this._guide
|
||||
|| options.selected && !this._selected
|
||||
|| (type = options.type) && (typeof type === 'string'
|
||||
// Support legacy Item#type property to match hyphenated
|
||||
// class-names.
|
||||
? type !== Base.hyphenate(this._class)
|
||||
: !(this instanceof type))),
|
||||
// Support legacy Item#type property to match hyphenated
|
||||
// class-names.
|
||||
|| options.type && options.type !== Base.hyphenate(this._class)
|
||||
|| options.class && !(this instanceof options.class)),
|
||||
that = this,
|
||||
res;
|
||||
|
||||
|
|
|
@ -236,9 +236,10 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
|
|||
}, /** @lends CompoundPath# */{
|
||||
_getChildHitTestOptions: function(options) {
|
||||
// If we're not specifically asked to returns paths through
|
||||
// options.type == Path, do not test children for fill, since a
|
||||
// compound path forms one shape. Also support legacy format 'path'
|
||||
return options.type === Path || typeof type === 'path'
|
||||
// options.class == Path, do not test children for fill, since a
|
||||
// compound path forms one shape.
|
||||
// Also support legacy format `type: 'path'`.
|
||||
return options.class === Path || options.type === 'path'
|
||||
? options
|
||||
: new Base(options, { fill: false });
|
||||
},
|
||||
|
|
|
@ -268,9 +268,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
* <b>options.tolerance:</b> {@code Number} – the tolerance of the hit test
|
||||
* in points, can also be controlled through
|
||||
* {@link Project#options}{@code .hitTolerance}.
|
||||
* <b>options.type:</b> Only hit test again a certain item type:
|
||||
* {@code Group, Layer, Path, CompoundPath, Shape, Raster, PlacedSymbol,
|
||||
* PointText}, etc.
|
||||
* <b>options.class:</b> Only hit test again a certain item class and its
|
||||
* sub-classes: {@code Group, Layer, Path, CompoundPath, Shape, Raster,
|
||||
* PlacedSymbol, PointText}, etc.
|
||||
* <b>options.fill:</b> {@code Boolean} – hit test the fill of items.
|
||||
* <b>options.stroke:</b> {@code Boolean} – hit test the stroke of path
|
||||
* items, taking into account the setting of stroke color and width.
|
||||
|
|
Loading…
Reference in a new issue