mirror of https://github.com/ElemeFE/element
ColorPicker: active-change only triggers on user interaction (#10903)
* ColorPicker: only emit active-change event source from dropdown, fixed #10901 * Update main.vuepull/10944/head
parent
61a25c5553
commit
a8248ddfef
|
@ -63,12 +63,9 @@
|
||||||
displayedColor() {
|
displayedColor() {
|
||||||
if (!this.value && !this.showPanelColor) {
|
if (!this.value && !this.showPanelColor) {
|
||||||
return 'transparent';
|
return 'transparent';
|
||||||
} else {
|
|
||||||
const { r, g, b } = this.color.toRgb();
|
|
||||||
return this.showAlpha
|
|
||||||
? `rgba(${ r }, ${ g }, ${ b }, ${ this.color.get('alpha') / 100 })`
|
|
||||||
: `rgb(${ r }, ${ g }, ${ b })`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.displayedRgb(this.color, this.showAlpha);
|
||||||
},
|
},
|
||||||
|
|
||||||
_elFormItemSize() {
|
_elFormItemSize() {
|
||||||
|
@ -99,7 +96,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
displayedColor(val) {
|
displayedColor(val) {
|
||||||
this.$emit('active-change', val);
|
const outerColor = new Color({
|
||||||
|
enableAlpha: this.showAlpha,
|
||||||
|
format: this.colorFormat
|
||||||
|
});
|
||||||
|
outerColor.fromString(this.value);
|
||||||
|
|
||||||
|
const outerColorRgb = this.displayedRgb(outerColor, this.showAlpha);
|
||||||
|
if (val !== outerColorRgb) {
|
||||||
|
this.$emit('active-change', val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -132,6 +138,16 @@
|
||||||
this.showPanelColor = false;
|
this.showPanelColor = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
displayedRgb(color, showAlpha) {
|
||||||
|
if (!(color instanceof Color)) {
|
||||||
|
throw Error('color should be instance of Color Class');
|
||||||
|
}
|
||||||
|
|
||||||
|
const { r, g, b } = color.toRgb();
|
||||||
|
return showAlpha
|
||||||
|
? `rgba(${ r }, ${ g }, ${ b }, ${ color.get('alpha') / 100 })`
|
||||||
|
: `rgb(${ r }, ${ g }, ${ b })`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue