mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
allow hitStrokeWidth usage, even if a shape has not stroke visible. fix #782
This commit is contained in:
@@ -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) {
|
||||
|
10
src/Shape.ts
10
src/Shape.ts
@@ -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
|
||||
|
@@ -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}
|
||||
|
Reference in New Issue
Block a user