Skip to content

Commit

Permalink
fix: lineDash支持多位数组
Browse files Browse the repository at this point in the history
  • Loading branch information
HuangLiangchen committed Dec 10, 2024
1 parent db6f50b commit 7ac7d37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion packages/g-lite/src/css/StyleValueRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
if (list.has('lineDash') && !isNil(attributes.lineDash)) {
object.parsedStyle.lineDash = parseDimensionArrayFormat(
attributes.lineDash,
2,
);
}
// @ts-ignore
Expand Down
23 changes: 13 additions & 10 deletions packages/g-lite/src/css/parser/dimension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function convertAngleUnit(value: CSSUnitValue) {

export function parseDimensionArrayFormat(
string: string | number | (string | number)[],
size: number,
size?: 2 | 4,
): number[] {
let parsed: number[];

Expand All @@ -185,16 +185,19 @@ export function parseDimensionArrayFormat(
}
return [parsed[0], parsed[1]];
}
if (parsed.length === 1) {
return [parsed[0], parsed[0], parsed[0], parsed[0]];
}
if (parsed.length === 2) {
return [parsed[0], parsed[1], parsed[0], parsed[1]];
}
if (parsed.length === 3) {
return [parsed[0], parsed[1], parsed[2], parsed[1]];
if (size === 4) {
if (parsed.length === 1) {
return [parsed[0], parsed[0], parsed[0], parsed[0]];
}
if (parsed.length === 2) {
return [parsed[0], parsed[1], parsed[0], parsed[1]];
}
if (parsed.length === 3) {
return [parsed[0], parsed[1], parsed[2], parsed[1]];
}
return [parsed[0], parsed[1], parsed[2], parsed[3]];
}
return [parsed[0], parsed[1], parsed[2], parsed[3]];
return parsed;
}

export function parseDimensionArray(
Expand Down

0 comments on commit 7ac7d37

Please sign in to comment.