fix: 取色器 Hue 值异常(#32)

This commit is contained in:
pipipi-pikachu 2021-05-27 22:01:33 +08:00
parent 7d823d84c6
commit 250c01b0ad
3 changed files with 5 additions and 7 deletions

View File

@ -37,7 +37,7 @@ export default defineComponent({
const color = computed(() => {
const hsla = tinycolor(props.value).toHsl()
if (hsla.s === 0) hsla.h = props.hue
hsla.h = props.hue
return hsla
})
@ -68,7 +68,7 @@ export default defineComponent({
else if (left > containerWidth) h = 360
else {
percent = left * 100 / containerWidth
h = (360 * percent / 100)
h = 360 * percent / 100
}
if (color.value.h !== h) {
emit('colorChange', {

View File

@ -39,7 +39,7 @@ export default defineComponent({
setup(props, { emit }) {
const color = computed(() => {
const hsva = tinycolor(props.value).toHsv()
if (hsva.s === 0) hsva.h = props.hue
hsva.h = props.hue
return hsva
})

View File

@ -189,10 +189,8 @@ export default defineComponent({
})
const changeColor = (value: ColorFormats.RGBA | ColorFormats.HSLA | ColorFormats.HSVA) => {
if ('h' in value) {
hue.value = value.h
color.value = tinycolor(value).toRgb()
}
if ('h' in value && 'l' in value) hue.value = value.h
if ('h' in value) color.value = tinycolor(value).toRgb()
else color.value = value
updateRecentColorsCache()