Fix color picker's broken gradient stop selection due to Svelte 5 not treating components as classes
This commit is contained in:
parent
5e61d59e50
commit
3488d5b8e7
|
|
@ -286,9 +286,7 @@
|
||||||
const colorToEmit = color || new Color({ h: hue, s: saturation, v: value, a: alpha });
|
const colorToEmit = color || new Color({ h: hue, s: saturation, v: value, a: alpha });
|
||||||
|
|
||||||
const stop = gradientSpectrumInputWidget && activeIndex !== undefined && gradient?.atIndex(activeIndex);
|
const stop = gradientSpectrumInputWidget && activeIndex !== undefined && gradient?.atIndex(activeIndex);
|
||||||
if (stop && gradientSpectrumInputWidget instanceof SpectrumInput) {
|
if (stop) stop.color = colorToEmit;
|
||||||
stop.color = colorToEmit;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch("colorOrGradient", gradient || colorToEmit);
|
dispatch("colorOrGradient", gradient || colorToEmit);
|
||||||
}
|
}
|
||||||
|
|
@ -347,17 +345,17 @@
|
||||||
|
|
||||||
function setColorPreset(preset: PresetColors) {
|
function setColorPreset(preset: PresetColors) {
|
||||||
dispatch("startHistoryTransaction");
|
dispatch("startHistoryTransaction");
|
||||||
|
|
||||||
if (preset === "none") {
|
if (preset === "none") {
|
||||||
setNewHSVA(0, 0, 0, 1, true);
|
setNewHSVA(0, 0, 0, 1, true);
|
||||||
setColor(new Color("none"));
|
setColor(new Color("none"));
|
||||||
return;
|
} else {
|
||||||
|
const presetColor = new Color(...PURE_COLORS[preset], 1);
|
||||||
|
const hsva = presetColor.toHSVA() || { h: 0, s: 0, v: 0, a: 0 };
|
||||||
|
|
||||||
|
setNewHSVA(hsva.h, hsva.s, hsva.v, hsva.a, false);
|
||||||
|
setColor(presetColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
const presetColor = new Color(...PURE_COLORS[preset], 1);
|
|
||||||
const hsva = presetColor.toHSVA() || { h: 0, s: 0, v: 0, a: 0 };
|
|
||||||
|
|
||||||
setNewHSVA(hsva.h, hsva.s, hsva.v, hsva.a, false);
|
|
||||||
setColor(presetColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNewHSVA(h: number, s: number, v: number, a: number, none: boolean) {
|
function setNewHSVA(h: number, s: number, v: number, a: number, none: boolean) {
|
||||||
|
|
@ -479,9 +477,7 @@
|
||||||
<SpectrumInput
|
<SpectrumInput
|
||||||
{gradient}
|
{gradient}
|
||||||
{disabled}
|
{disabled}
|
||||||
on:gradient={() => {
|
on:gradient={() => dispatch("colorOrGradient", gradient)}
|
||||||
if (gradient) dispatch("colorOrGradient", gradient);
|
|
||||||
}}
|
|
||||||
on:activeMarkerIndexChange={gradientActiveMarkerIndexChange}
|
on:activeMarkerIndexChange={gradientActiveMarkerIndexChange}
|
||||||
activeMarkerIndex={activeIndex}
|
activeMarkerIndex={activeIndex}
|
||||||
on:dragging={({ detail }) => (gradientSpectrumDragging = detail)}
|
on:dragging={({ detail }) => (gradientSpectrumDragging = detail)}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@ export function createTooltipState(editor: Editor) {
|
||||||
// Before we schedule a new future tooltip appearance, we clear the existing one
|
// Before we schedule a new future tooltip appearance, we clear the existing one
|
||||||
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
||||||
|
|
||||||
|
// Don't show tooltips while mouse buttons are pressed
|
||||||
|
if (e.buttons !== 0) return;
|
||||||
|
|
||||||
// Schedule the tooltip to appear at this cursor position after a delay
|
// Schedule the tooltip to appear at this cursor position after a delay
|
||||||
tooltipTimeout = setTimeout(() => {
|
tooltipTimeout = setTimeout(() => {
|
||||||
update((state) => {
|
update((state) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue