fix fillPattern cache

This commit is contained in:
Anton Lavrenov 2021-08-04 18:34:22 +07:00
parent 0357a1e7b4
commit 08c8a78451
7 changed files with 18 additions and 7 deletions

View File

@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 8.1.3
- Fix `fillPattern` cache invalidation on shapes
## 8.1.2
- Fix memory leak for `Konva.Image`

View File

@ -7096,7 +7096,7 @@
Shape.prototype.eventListeners = {};
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetX.konva fillPatternOffsetY.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotation.konva', _clearFillPatternCache);
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
// add getters and setters
@ -11586,6 +11586,8 @@
}
_setImageLoad() {
const image = this.image();
console.log(image && image.complete);
console.log(image && image.readyState === 4);
// check is image is already loaded
if (image && image.complete) {
return;
@ -11596,6 +11598,7 @@
}
if (image && image['addEventListener']) {
image['addEventListener']('load', () => {
console.log('onload');
this._requestDraw();
});
}

2
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -848,7 +848,7 @@ Shape.prototype.on.call(
Shape.prototype.on.call(
Shape.prototype,
'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetX.konva fillPatternOffsetY.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotation.konva',
'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva',
_clearFillPatternCache
);

View File

@ -142,7 +142,7 @@ describe('AutoDraw', function () {
) as HTMLImageElement;
const img = new Image();
img.src = src;
img.src = src + '?'; // change url to reset cache
const image = new Konva.Image({
image: img,
});

View File

@ -1860,6 +1860,12 @@ describe('Shape', function () {
assert.notEqual(pattern4, pattern3);
star.fillPatternOffsetX(10);
var pattern5 = star._getFillPattern();
assert.notEqual(pattern4, pattern5);
done();
});
});

View File

@ -36,7 +36,7 @@ function simulateMouseUp(tr: Transformer, pos = { x: 0, y: 0 }) {
su(tr.getStage(), pos || { x: 1, y: 1 });
}
describe.only('Transformer', function () {
describe('Transformer', function () {
// ======================================================
it('init transformer on simple rectangle', function () {
var stage = addStage();
@ -4025,7 +4025,6 @@ describe.only('Transformer', function () {
// make sure drag also triggers on the transformer.
tr.on('dragstart', (e) => {
assert.equal(!!e.evt, true);
console.log('transfomer');
dragstart += 1;
});
tr.on('dragmove', () => {
@ -4040,7 +4039,6 @@ describe.only('Transformer', function () {
stage.on('dragstart', (e) => {
assert.equal(!!e.evt, true);
dragstart += 1;
console.log('stage', e.target);
});
layer.add(tr);