mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
update CHANGELOG with new version
This commit is contained in:
@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## Not released:
|
||||
|
||||
## 4.2.2 - 2020-03-26
|
||||
|
||||
* Fix hit stroke issues
|
||||
|
||||
## 4.2.1 - 2020-03-26
|
||||
|
||||
* Fix some issues with `mouseenter` and `mouseleave` events.
|
||||
|
9
konva.js
9
konva.js
@@ -7250,10 +7250,13 @@
|
||||
};
|
||||
Shape.prototype.hasHitStroke = function () {
|
||||
var width = this.hitStrokeWidth();
|
||||
// we should enable hit stroke we stroke is enabled
|
||||
// on auto just check by stroke
|
||||
if (width === 'auto') {
|
||||
return this.hasStroke();
|
||||
}
|
||||
// we should enable hit stroke if stroke is enabled
|
||||
// and we have some value from width
|
||||
return (this.strokeEnabled() &&
|
||||
(width || (this.strokeWidth() && width === 'auto')));
|
||||
return this.strokeEnabled() && !!width;
|
||||
};
|
||||
/**
|
||||
* determines if point is in the shape, regardless if other shapes are on top of it. Note: because
|
||||
|
2
konva.min.js
vendored
2
konva.min.js
vendored
File diff suppressed because one or more lines are too long
12
src/Shape.ts
12
src/Shape.ts
@@ -376,12 +376,14 @@ export class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<
|
||||
hasHitStroke() {
|
||||
const width = this.hitStrokeWidth();
|
||||
|
||||
// we should enable hit stroke we stroke is enabled
|
||||
// on auto just check by stroke
|
||||
if (width === 'auto') {
|
||||
return this.hasStroke();
|
||||
}
|
||||
|
||||
// we should enable hit stroke if stroke is enabled
|
||||
// and we have some value from width
|
||||
return (
|
||||
this.strokeEnabled() &&
|
||||
(width || (this.strokeWidth() && width === 'auto'))
|
||||
);
|
||||
return this.strokeEnabled() && !!width;
|
||||
}
|
||||
/**
|
||||
* determines if point is in the shape, regardless if other shapes are on top of it. Note: because
|
||||
|
@@ -402,6 +402,32 @@ suite('Line', function() {
|
||||
);
|
||||
});
|
||||
|
||||
test('hit test for scaled line', function() {
|
||||
var stage = addStage();
|
||||
var scale = 42;
|
||||
stage.scaleX(scale);
|
||||
stage.scaleY(scale);
|
||||
var layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
|
||||
var points = [1, 1, 7, 2, 8, 7, 2, 6];
|
||||
var line = new Konva.Line({
|
||||
points: points.map(function(v) {
|
||||
return (v * 20) / scale;
|
||||
}),
|
||||
closed: true,
|
||||
fill: 'green',
|
||||
draggable: true
|
||||
});
|
||||
layer.add(line);
|
||||
layer.draw();
|
||||
|
||||
assert.equal(line.hasHitStroke(), false);
|
||||
assert.equal(layer.getIntersection({ x: 1, y: 1 }), null);
|
||||
|
||||
layer.toggleHitCanvas();
|
||||
});
|
||||
|
||||
test('getClientRect with scaling', function() {
|
||||
var stage = addStage();
|
||||
var scale = 42;
|
||||
@@ -416,9 +442,11 @@ suite('Line', function() {
|
||||
return (v * 20) / scale;
|
||||
}),
|
||||
closed: true,
|
||||
fill: 'green'
|
||||
fill: 'green',
|
||||
draggable: true
|
||||
});
|
||||
layer.add(line);
|
||||
layer.draw();
|
||||
|
||||
var client = line.getClientRect();
|
||||
|
||||
|
Reference in New Issue
Block a user