Merge pull request #9 from fsih/hitUnfilledText

Allow hitting unfilled text and compound paths when hitUnfilledPaths option is on
This commit is contained in:
DD Liu 2018-04-11 14:32:35 -04:00 committed by GitHub
commit a9de479c8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -293,7 +293,7 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
// options.class == Path, do not test children for fill, since a
// compound path forms one shape.
// Also support legacy format `type: 'path'`.
options.class === Path || options.type === 'path' ? options
options.class === Path || options.type === 'path' || options.hitUnfilledPaths ? options
: Base.set({}, options, { fill: false }),
viewMatrix);
},

View file

@ -119,5 +119,10 @@ var PointText = TextItem.extend(/** @lends PointText# */{
numLines ? - 0.75 * leading : 0,
width, numLines * leading);
return matrix ? matrix._transformBounds(rect, rect) : rect;
},
_hitTestSelf: function(point, options) {
if (options.fill && (this.hasFill() || options.hitUnfilledPaths) && this._contains(point))
return new HitResult('fill', this);
}
});