mirror of
https://github.com/konvajs/konva.git
synced 2026-01-23 13:26:07 +08:00
Fix correct rendering of Konva.Label when heigh of text is changed
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
* Fix correct rendering of `Konva.Label` when heigh of text is changed
|
||||||
|
|
||||||
## 7.2.0
|
## 7.2.0
|
||||||
|
|
||||||
* New property `fillAfterStrokeEnabled` for `Konva.Shape`. See API docs for more information.
|
* New property `fillAfterStrokeEnabled` for `Konva.Shape`. See API docs for more information.
|
||||||
|
|||||||
11
konva.js
11
konva.js
@@ -8,7 +8,7 @@
|
|||||||
* Konva JavaScript Framework v7.2.0
|
* Konva JavaScript Framework v7.2.0
|
||||||
* http://konvajs.org/
|
* http://konvajs.org/
|
||||||
* Licensed under the MIT
|
* Licensed under the MIT
|
||||||
* Date: Mon Nov 23 2020
|
* Date: Wed Nov 25 2020
|
||||||
*
|
*
|
||||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||||
@@ -11272,7 +11272,8 @@
|
|||||||
'padding',
|
'padding',
|
||||||
'lineHeight',
|
'lineHeight',
|
||||||
'text',
|
'text',
|
||||||
'width'
|
'width',
|
||||||
|
'height',
|
||||||
], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left',
|
], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left',
|
||||||
// cached variables
|
// cached variables
|
||||||
attrChangeListLen = ATTR_CHANGE_LIST.length;
|
attrChangeListLen = ATTR_CHANGE_LIST.length;
|
||||||
@@ -11411,11 +11412,11 @@
|
|||||||
x: -1 * x,
|
x: -1 * x,
|
||||||
y: -1 * y,
|
y: -1 * y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height,
|
||||||
});
|
});
|
||||||
text.setAttrs({
|
text.setAttrs({
|
||||||
x: -1 * x,
|
x: -1 * x,
|
||||||
y: -1 * y
|
y: -1 * y,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -11510,7 +11511,7 @@
|
|||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
return Tag;
|
return Tag;
|
||||||
|
|||||||
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -3,7 +3,10 @@ import { Factory } from '../Factory';
|
|||||||
import { Shape, ShapeConfig } from '../Shape';
|
import { Shape, ShapeConfig } from '../Shape';
|
||||||
import { Group } from '../Group';
|
import { Group } from '../Group';
|
||||||
import { ContainerConfig } from '../Container';
|
import { ContainerConfig } from '../Container';
|
||||||
import {getNumberOrArrayOfNumbersValidator, getNumberValidator} from '../Validators';
|
import {
|
||||||
|
getNumberOrArrayOfNumbersValidator,
|
||||||
|
getNumberValidator,
|
||||||
|
} from '../Validators';
|
||||||
import { _registerNode } from '../Global';
|
import { _registerNode } from '../Global';
|
||||||
|
|
||||||
import { GetSet } from '../types';
|
import { GetSet } from '../types';
|
||||||
@@ -18,7 +21,8 @@ var ATTR_CHANGE_LIST = [
|
|||||||
'padding',
|
'padding',
|
||||||
'lineHeight',
|
'lineHeight',
|
||||||
'text',
|
'text',
|
||||||
'width'
|
'width',
|
||||||
|
'height',
|
||||||
],
|
],
|
||||||
CHANGE_KONVA = 'Change.konva',
|
CHANGE_KONVA = 'Change.konva',
|
||||||
NONE = 'none',
|
NONE = 'none',
|
||||||
@@ -70,7 +74,7 @@ var ATTR_CHANGE_LIST = [
|
|||||||
export class Label extends Group {
|
export class Label extends Group {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
super(config);
|
super(config);
|
||||||
this.on('add.konva', function(evt) {
|
this.on('add.konva', function (evt) {
|
||||||
this._addListeners(evt.child);
|
this._addListeners(evt.child);
|
||||||
this._sync();
|
this._sync();
|
||||||
});
|
});
|
||||||
@@ -99,7 +103,7 @@ export class Label extends Group {
|
|||||||
_addListeners(text) {
|
_addListeners(text) {
|
||||||
var that = this,
|
var that = this,
|
||||||
n;
|
n;
|
||||||
var func = function() {
|
var func = function () {
|
||||||
that._sync();
|
that._sync();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -157,12 +161,12 @@ export class Label extends Group {
|
|||||||
x: -1 * x,
|
x: -1 * x,
|
||||||
y: -1 * y,
|
y: -1 * y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height,
|
||||||
});
|
});
|
||||||
|
|
||||||
text.setAttrs({
|
text.setAttrs({
|
||||||
x: -1 * x,
|
x: -1 * x,
|
||||||
y: -1 * y
|
y: -1 * y,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -277,13 +281,7 @@ export class Tag extends Shape<TagConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.lineTo(0, topLeft);
|
context.lineTo(0, topLeft);
|
||||||
context.arc(
|
context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
|
||||||
topLeft,
|
|
||||||
topLeft,
|
|
||||||
topLeft,
|
|
||||||
Math.PI,
|
|
||||||
(Math.PI * 3) / 2,
|
|
||||||
false);
|
|
||||||
|
|
||||||
context.closePath();
|
context.closePath();
|
||||||
context.fillStrokeShape(this);
|
context.fillStrokeShape(this);
|
||||||
@@ -313,7 +311,7 @@ export class Tag extends Shape<TagConfig> {
|
|||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,6 +372,11 @@ Factory.addGetterSetter(Tag, 'pointerHeight', 0, getNumberValidator());
|
|||||||
* tag.cornerRadius([0, 10, 20, 30]);
|
* tag.cornerRadius([0, 10, 20, 30]);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Factory.addGetterSetter(Tag, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
Factory.addGetterSetter(
|
||||||
|
Tag,
|
||||||
|
'cornerRadius',
|
||||||
|
0,
|
||||||
|
getNumberOrArrayOfNumbersValidator(4)
|
||||||
|
);
|
||||||
|
|
||||||
Collection.mapMethods(Tag);
|
Collection.mapMethods(Tag);
|
||||||
|
|||||||
@@ -277,6 +277,9 @@ suite('Label', function () {
|
|||||||
|
|
||||||
layer.draw();
|
layer.draw();
|
||||||
assert.equal(tag.width(), text.width());
|
assert.equal(tag.width(), text.width());
|
||||||
|
|
||||||
|
text.height(200);
|
||||||
|
assert.equal(tag.height(), text.height());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('tag cornerRadius', function () {
|
test('tag cornerRadius', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user