mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
deprecate getTextHeight
This commit is contained in:
@@ -17,6 +17,7 @@ That changes are private and internal specific. They should not break most of `K
|
|||||||
* Removed polyfill for `requestAnimationFrame`.
|
* Removed polyfill for `requestAnimationFrame`.
|
||||||
* `id` and `name` properties defaults are empty strings, not `undefined`
|
* `id` and `name` properties defaults are empty strings, not `undefined`
|
||||||
* internal `_cache` property was updated to use es2015 `Map` instead of `{}`.
|
* internal `_cache` property was updated to use es2015 `Map` instead of `{}`.
|
||||||
|
* `text.getTextHeight()` is deprecated. Use `text.height()` or `text.fontSize()` instead.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Show a warning when a stage has too many layers
|
* Show a warning when a stage has too many layers
|
||||||
|
12
konva.js
12
konva.js
@@ -12502,7 +12502,7 @@
|
|||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
Text.prototype._sceneFunc = function (context) {
|
Text.prototype._sceneFunc = function (context) {
|
||||||
var padding = this.padding(), textHeight = this.getTextHeight(), lineHeightPx = this.lineHeight() * textHeight, textArr = this.textArr, textArrLen = textArr.length, verticalAlign = this.verticalAlign(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), fontSize = this.fontSize(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;
|
var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, textArr = this.textArr, textArrLen = textArr.length, verticalAlign = this.verticalAlign(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n;
|
||||||
context.setAttr('font', this._getContextFont());
|
context.setAttr('font', this._getContextFont());
|
||||||
context.setAttr('textBaseline', MIDDLE);
|
context.setAttr('textBaseline', MIDDLE);
|
||||||
context.setAttr('textAlign', LEFT$1);
|
context.setAttr('textAlign', LEFT$1);
|
||||||
@@ -12607,7 +12607,7 @@
|
|||||||
Text.prototype.getHeight = function () {
|
Text.prototype.getHeight = function () {
|
||||||
var isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;
|
var isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;
|
||||||
return isAuto
|
return isAuto
|
||||||
? this.getTextHeight() * this.textArr.length * this.lineHeight() +
|
? this.fontSize() * this.textArr.length * this.lineHeight() +
|
||||||
this.padding() * 2
|
this.padding() * 2
|
||||||
: this.attrs.height;
|
: this.attrs.height;
|
||||||
};
|
};
|
||||||
@@ -12620,14 +12620,8 @@
|
|||||||
Text.prototype.getTextWidth = function () {
|
Text.prototype.getTextWidth = function () {
|
||||||
return this.textWidth;
|
return this.textWidth;
|
||||||
};
|
};
|
||||||
// TODO: deprecate and remove the method
|
|
||||||
/**
|
|
||||||
* get height of one line of text
|
|
||||||
* @method
|
|
||||||
* @name Konva.Text#getTextHeight
|
|
||||||
* @returns {Number}
|
|
||||||
*/
|
|
||||||
Text.prototype.getTextHeight = function () {
|
Text.prototype.getTextHeight = function () {
|
||||||
|
Util.warn('text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.');
|
||||||
return this.textHeight;
|
return this.textHeight;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
2
konva.min.js
vendored
2
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -123,8 +123,8 @@ export class Text extends Shape {
|
|||||||
|
|
||||||
_sceneFunc(context) {
|
_sceneFunc(context) {
|
||||||
var padding = this.padding(),
|
var padding = this.padding(),
|
||||||
textHeight = this.getTextHeight(),
|
fontSize = this.fontSize(),
|
||||||
lineHeightPx = this.lineHeight() * textHeight,
|
lineHeightPx = this.lineHeight() * fontSize,
|
||||||
textArr = this.textArr,
|
textArr = this.textArr,
|
||||||
textArrLen = textArr.length,
|
textArrLen = textArr.length,
|
||||||
verticalAlign = this.verticalAlign(),
|
verticalAlign = this.verticalAlign(),
|
||||||
@@ -133,7 +133,6 @@ export class Text extends Shape {
|
|||||||
totalWidth = this.getWidth(),
|
totalWidth = this.getWidth(),
|
||||||
letterSpacing = this.letterSpacing(),
|
letterSpacing = this.letterSpacing(),
|
||||||
fill = this.fill(),
|
fill = this.fill(),
|
||||||
fontSize = this.fontSize(),
|
|
||||||
textDecoration = this.textDecoration(),
|
textDecoration = this.textDecoration(),
|
||||||
shouldUnderline = textDecoration.indexOf('underline') !== -1,
|
shouldUnderline = textDecoration.indexOf('underline') !== -1,
|
||||||
shouldLineThrough = textDecoration.indexOf('line-through') !== -1,
|
shouldLineThrough = textDecoration.indexOf('line-through') !== -1,
|
||||||
@@ -263,7 +262,7 @@ export class Text extends Shape {
|
|||||||
getHeight() {
|
getHeight() {
|
||||||
var isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;
|
var isAuto = this.attrs.height === AUTO || this.attrs.height === undefined;
|
||||||
return isAuto
|
return isAuto
|
||||||
? this.getTextHeight() * this.textArr.length * this.lineHeight() +
|
? this.fontSize() * this.textArr.length * this.lineHeight() +
|
||||||
this.padding() * 2
|
this.padding() * 2
|
||||||
: this.attrs.height;
|
: this.attrs.height;
|
||||||
}
|
}
|
||||||
@@ -276,14 +275,10 @@ export class Text extends Shape {
|
|||||||
getTextWidth() {
|
getTextWidth() {
|
||||||
return this.textWidth;
|
return this.textWidth;
|
||||||
}
|
}
|
||||||
// TODO: deprecate and remove the method
|
|
||||||
/**
|
|
||||||
* get height of one line of text
|
|
||||||
* @method
|
|
||||||
* @name Konva.Text#getTextHeight
|
|
||||||
* @returns {Number}
|
|
||||||
*/
|
|
||||||
getTextHeight() {
|
getTextHeight() {
|
||||||
|
Util.warn(
|
||||||
|
'text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.'
|
||||||
|
);
|
||||||
return this.textHeight;
|
return this.textHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user