Merge pull request #1795 from kyechan99/master

fix: specify type
This commit is contained in:
Anton Lavrenov 2024-07-19 10:35:33 -05:00 committed by GitHub
commit 9830a6c37c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 13 deletions

View File

@ -235,8 +235,8 @@ export class Path extends Shape<PathConfig> {
return pathLength; return pathLength;
} }
static getPointAtLengthOfDataArray(length: number, dataArray) { static getPointAtLengthOfDataArray(length: number, dataArray: PathSegment[]) {
var point, var points: number[],
i = 0, i = 0,
ii = dataArray.length; ii = dataArray.length;
@ -250,18 +250,18 @@ export class Path extends Shape<PathConfig> {
} }
if (i === ii) { if (i === ii) {
point = dataArray[i - 1].points.slice(-2); points = dataArray[i - 1].points.slice(-2);
return { return {
x: point[0], x: points[0],
y: point[1], y: points[1],
}; };
} }
if (length < 0.01) { if (length < 0.01) {
point = dataArray[i].points.slice(0, 2); points = dataArray[i].points.slice(0, 2);
return { return {
x: point[0], x: points[0],
y: point[1], y: points[1],
}; };
} }
@ -319,7 +319,15 @@ export class Path extends Shape<PathConfig> {
return null; return null;
} }
static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX?, fromY?) { static getPointOnLine(
dist: number,
P1x: number,
P1y: number,
P2x: number,
P2y: number,
fromX?: number,
fromY?: number
) {
fromX = fromX ?? P1x; fromX = fromX ?? P1x;
fromY = fromY ?? P1y; fromY = fromY ?? P1y;

View File

@ -392,13 +392,13 @@ export class Text extends Shape<TextConfig> {
* That method can't handle multiline text. * That method can't handle multiline text.
* @method * @method
* @name Konva.Text#measureSize * @name Konva.Text#measureSize
* @param {String} [text] text to measure * @param {String} text text to measure
* @returns {Object} { width , height} of measured text * @returns {Object} { width , height } of measured text
*/ */
measureSize(text) { measureSize(text: string) {
var _context = getDummyContext(), var _context = getDummyContext(),
fontSize = this.fontSize(), fontSize = this.fontSize(),
metrics; metrics: TextMetrics;
_context.save(); _context.save();
_context.font = this._getContextFont(); _context.font = this._getContextFont();