allow hitStrokeWidth usage, even if a shape has not stroke visible. fix #782

This commit is contained in:
Anton Lavrenov
2019-11-08 11:37:10 -05:00
parent 713c3d71c4
commit bb68b3f1a8
6 changed files with 53 additions and 7 deletions

View File

@@ -826,7 +826,7 @@ export class HitContext extends Context {
this.restore();
}
_stroke(shape) {
if (shape.hasStroke() && shape.hitStrokeWidth()) {
if (shape.hasHitStroke()) {
// ignore strokeScaleEnabled for Text
var strokeScaleEnabled = shape.getStrokeScaleEnabled();
if (!strokeScaleEnabled) {

View File

@@ -370,6 +370,16 @@ export class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<
// this.getStrokeRadialGradientColorStops()
);
}
hasHitStroke() {
const width = this.hitStrokeWidth();
// we should enable hit stroke we stroke is enabled
// and we have some value from width
return (
this.strokeEnabled() &&
(width || this.strokeWidth() && width === 'auto')
);
}
/**
* determines if point is in the shape, regardless if other shapes are on top of it. Note: because
* this method clears a temporary canvas and then redraws the shape, it performs very poorly if executed many times

View File

@@ -241,7 +241,9 @@ export class Stage extends Container<BaseLayer> {
return this;
}
/**
* get pointer position which can be a touch position or mouse position
* returns absolute pointer position which can be a touch position or mouse position
* pointer position doesn't include any transforms (such as scale) of the stage
* it is just a plain position of pointer relative to top-left corner of the stage container
* @method
* @name Konva.Stage#getPointerPosition
* @returns {Vector2d|null}