Skip to content

Commit

Permalink
fix: 修复color-picker中css渐变不支持hex色值问题
Browse files Browse the repository at this point in the history
  • Loading branch information
huangchen1031 committed Sep 19, 2024
1 parent dd011af commit 7a8e5f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/color-picker/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ export class Color {
if (input === this.originColor) {
return;
}
if (this.isGradient) {
// 处理gradient模式下切换不同格式时的交互问题
const gradientColors = parseGradientString(input);
if (this.isGradient && !gradientColors) {
// 处理gradient模式下切换不同格式时的交互问题,输入的不是渐变字符串才使用当前处理
const colorHsv = tinyColor(input).toHsv();
this.states = colorHsv;
this.updateCurrentGradientColor();
return;
}
this.originColor = input;
this.isGradient = false;
const gradientColors = parseGradientString(input);
let colorInput = input;
if (gradientColors) {
this.isGradient = true;
Expand Down Expand Up @@ -295,7 +295,7 @@ export class Color {
color: this.rgba,
};
gradientColors.splice(index, 1, newColor);
this.gradientColors = gradientColors;
this.gradientColors = gradientColors.slice();
return this;
}

Expand Down

0 comments on commit 7a8e5f9

Please sign in to comment.