diff --git a/src/renderer/src/components/common/HSVInput.vue b/src/renderer/src/components/common/HSVInput.vue index 10d58f3..bf308e7 100644 --- a/src/renderer/src/components/common/HSVInput.vue +++ b/src/renderer/src/components/common/HSVInput.vue @@ -131,6 +131,7 @@ " /> @@ -152,6 +153,7 @@ }" /> @@ -171,6 +173,7 @@ :style="{ background: `linear-gradient(90deg, black, ${valueSliderColor.hex()} 100%` }" /> @@ -266,6 +269,17 @@ const valueSliderColor = computed(() => { return Color.hsv(hueSliderModel.value[0], saturationSliderModel.value[0], 100) }) +const animateSliders = ref(false) +const disableAnimateSliders = useDebounceFn(() => { + animateSliders.value = false +}, 150) +const enableAnimateSliders = () => { + console.log('ANIMATE!!!') + animateSliders.value = true + disableAnimateSliders() +} +defineExpose({ enableAnimateSliders }) + const hexInput = ref('FF0000') const hueInput = ref('000') const saturationInput = ref('100') @@ -280,6 +294,7 @@ function onSubmitHexInput() { input = '#' + input } if (input.match(/^#[0-9A-F]{6}$/i)) { + enableAnimateSliders() color.value = Color(input) } else shake() } @@ -290,6 +305,7 @@ function onSubmitHueInput() { shake() return } + enableAnimateSliders() const newHue = Math.max(0, Math.min(input, 360)) if (newHue === color.value.hue()) { updateInputs() @@ -303,6 +319,7 @@ function onSubmitSaturationInput() { shake() return } + enableAnimateSliders() const newSaturation = Math.max(0, Math.min(input, 100)) if (newSaturation === color.value.saturationv()) { updateInputs() @@ -316,6 +333,7 @@ function onSubmitValueInput() { shake() return } + enableAnimateSliders() const newValue = Math.max(0, Math.min(input, 100)) if (newValue === color.value.value()) { updateInputs() @@ -331,6 +349,7 @@ function onSubmitRGBInput() { shake() return } + enableAnimateSliders() const newColor = Color.rgb(r, g, b) if (newColor.hex() === color.value.hex()) { updateInputs() diff --git a/src/renderer/src/components/common/PaletteInput.vue b/src/renderer/src/components/common/PaletteInput.vue index 67f981f..5d6f5e1 100644 --- a/src/renderer/src/components/common/PaletteInput.vue +++ b/src/renderer/src/components/common/PaletteInput.vue @@ -17,7 +17,12 @@ ? 'hover:bg-zinc-800 text-muted-foreground mx-[1px]' : 'text-black bg-zinc-300 hover:bg-zinc-200 border-x border-t border-zinc-100' " - @click="currentOption = key" + @click=" + () => { + enableAnimateSliders() + currentOption = key + } + " > {{ $t(option.titleKey) }} @@ -29,10 +34,16 @@ class="h-6 flex-1 transition-colors" :class="{ 'color-tab': currentOption === key }" :style="{ background: Color(option.colorNumber).hex() }" - @click="currentOption = key" + @click=" + () => { + enableAnimateSliders() + currentOption = key + } + " /> @@ -47,6 +58,8 @@ defineEmits(['input']) const currentOption = ref(null) +const hsvInput = ref(null) + const currentColorHex = computed(() => Color(props.options[currentOption.value].colorNumber).hex()) const props = defineProps({ @@ -69,6 +82,11 @@ const props = defineProps({ } }) +function enableAnimateSliders() { + hsvInput.value.enableAnimateSliders() +} +defineExpose({ enableAnimateSliders }) + onBeforeMount(() => { if (currentOption.value === null) currentOption.value = Object.keys(props.options)[0] }) diff --git a/src/renderer/src/components/config/keys/KeyLightConfig.vue b/src/renderer/src/components/config/keys/KeyLightConfig.vue index 3bee2dc..409618c 100644 --- a/src/renderer/src/components/config/keys/KeyLightConfig.vue +++ b/src/renderer/src/components/config/keys/KeyLightConfig.vue @@ -1,6 +1,7 @@