getting previous value before changes are made

This commit is contained in:
Andreas Henriksson 2024-03-28 15:02:06 +01:00
commit 28baee93b1

View file

@ -117,13 +117,14 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
function updateValue(isIncrementing) { function updateValue(isIncrementing) {
previousValue = ref.value;
if (isIncrementing) { if (isIncrementing) {
ref.stepUp(); ref.stepUp();
} else { } else {
ref.stepDown(); ref.stepDown();
} }
previousValue = ref.value;
value = +ref.value; value = +ref.value;
dispatch("input", value); dispatch("input", value);
@ -141,6 +142,10 @@
$: ariaLabel = $: ariaLabel =
$$props["aria-label"] || $$props["aria-label"] ||
"Numeric input field with increment and decrement buttons"; "Numeric input field with increment and decrement buttons";
$: {
console.log("previousValue / value", previousValue, value);
console.log();
}
function parse(raw) { function parse(raw) {
return raw != "" ? Number(raw) : null; return raw != "" ? Number(raw) : null;