fix(slider): dispatch change event in reactive statement

Removes afterUpdate method
This commit is contained in:
Eric Liu 2020-09-28 14:08:24 -07:00
commit 5e8915df7f

View file

@ -101,7 +101,7 @@
*/ */
export let ref = null; export let ref = null;
import { createEventDispatcher, afterUpdate } from "svelte"; import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -144,12 +144,6 @@
value = nextValue; value = nextValue;
} }
afterUpdate(() => {
if (!holding) {
dispatch("change", value);
}
});
$: range = max - min; $: range = max - min;
$: left = ((value - min) / range) * 100; $: left = ((value - min) / range) * 100;
$: { $: {
@ -163,6 +157,10 @@
calcValue(event); calcValue(event);
dragging = false; dragging = false;
} }
if (!holding) {
dispatch("change", value);
}
} }
</script> </script>