mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
getting previous value before changes are made
This commit is contained in:
parent
6b0ed4cc05
commit
28baee93b1
1 changed files with 6 additions and 1 deletions
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue