Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: specify type #1795

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/shapes/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ export class Path extends Shape<PathConfig> {
return pathLength;
}

static getPointAtLengthOfDataArray(length: number, dataArray) {
var point,
static getPointAtLengthOfDataArray(length: number, dataArray: PathSegment[]) {
var points: number[],
i = 0,
ii = dataArray.length;

Expand All @@ -250,18 +250,18 @@ export class Path extends Shape<PathConfig> {
}

if (i === ii) {
point = dataArray[i - 1].points.slice(-2);
points = dataArray[i - 1].points.slice(-2);
return {
x: point[0],
y: point[1],
x: points[0],
y: points[1],
};
}

if (length < 0.01) {
point = dataArray[i].points.slice(0, 2);
points = dataArray[i].points.slice(0, 2);
return {
x: point[0],
y: point[1],
x: points[0],
y: points[1],
};
}

Expand Down Expand Up @@ -319,7 +319,15 @@ export class Path extends Shape<PathConfig> {
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;
fromY = fromY ?? P1y;

Expand Down
8 changes: 4 additions & 4 deletions src/shapes/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,13 @@ export class Text extends Shape<TextConfig> {
* That method can't handle multiline text.
* @method
* @name Konva.Text#measureSize
* @param {String} [text] text to measure
* @returns {Object} { width , height} of measured text
* @param {String} text text to measure
* @returns {Object} { width , height } of measured text
*/
measureSize(text) {
measureSize(text: string) {
var _context = getDummyContext(),
fontSize = this.fontSize(),
metrics;
metrics: TextMetrics;

_context.save();
_context.font = this._getContextFont();
Expand Down
Loading