fix(slider): dont update slider if disabled

This commit is contained in:
Eric Liu 2020-09-28 14:10:30 -07:00
commit 4be4c498b6
2 changed files with 4 additions and 2 deletions

View file

@ -4,7 +4,7 @@
import Slider from "./Slider.svelte"; import Slider from "./Slider.svelte";
import SliderSkeleton from "./Slider.Skeleton.svelte"; import SliderSkeleton from "./Slider.Skeleton.svelte";
$: value = 50; let value = 50;
</script> </script>
{#if story === 'skeleton'} {#if story === 'skeleton'}

View file

@ -129,6 +129,8 @@
} }
function calcValue(e) { function calcValue(e) {
if (disabled) return;
const offsetX = e.touches ? e.touches[0].clientX : e.clientX; const offsetX = e.touches ? e.touches[0].clientX : e.clientX;
const { left, width } = trackRef.getBoundingClientRect(); const { left, width } = trackRef.getBoundingClientRect();
let nextValue = let nextValue =
@ -158,7 +160,7 @@
dragging = false; dragging = false;
} }
if (!holding) { if (!holding && !disabled) {
dispatch("change", value); dispatch("change", value);
} }
} }