diff --git a/src/item/Shape.js b/src/item/Shape.js index 6431592069..6b73e486e7 100644 --- a/src/item/Shape.js +++ b/src/item/Shape.js @@ -344,13 +344,17 @@ new function() { // Scope for _contains() and _hitTestSelf() code. _hitTestSelf: function _hitTestSelf(point, options, viewMatrix, strokeMatrix) { var hit = false, - style = this._style; - if (options.stroke && style.hasStroke()) { + style = this._style, + hitStroke = options.stroke && style.hasStroke(), + hitFill = options.fill && style.hasFill(); + // Just like in Path, use stroke-hit-tests also for hitting fill + // with tolerance: + if (hitStroke || hitFill) { var type = this._type, radius = this._radius, - strokeWidth = style.getStrokeWidth(), + strokeRadius = hitStroke ? style.getStrokeWidth() / 2 : 0; strokePadding = options._tolerancePadding.add( - Path._getStrokePadding(strokeWidth / 2, + Path._getStrokePadding(strokeRadius, !style.getStrokeScaling() && strokeMatrix)); if (type === 'rectangle') { var padding = strokePadding.multiply(2), @@ -370,7 +374,7 @@ new function() { // Scope for _contains() and _hitTestSelf() code. hit = isOnEllipseStroke(point, radius, strokePadding); } } - return hit ? new HitResult('stroke', this) + return hit ? new HitResult(hitStroke ? 'stroke' : 'fill', this) : _hitTestSelf.base.apply(this, arguments); } }; diff --git a/src/path/Path.js b/src/path/Path.js index 74225b505c..054bd8fd3d 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -1577,7 +1577,7 @@ var Path = PathItem.extend(/** @lends Path# */{ miterLimit = strokeRadius * style.getMiterLimit(); // Add the stroke radius to tolerance padding, taking // #strokeScaling into account through _getStrokeMatrix(). - strokePadding = tolerancePadding.add( + strokePadding = strokePadding.add( Path._getStrokePadding(strokeRadius, !style.getStrokeScaling() && strokeMatrix)); } else {