Skip to content

Commit

Permalink
update step
Browse files Browse the repository at this point in the history
  • Loading branch information
feruzm committed Mar 8, 2024
1 parent 1bb7639 commit bce8fca
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ interface Props {

export function ReactInputSliderWrapper({ value, onChange }: Props) {
const rootRef = useRef<HTMLSpanElement | null>(null);
const step = 0.1;

const handleKeyboard = (e: React.KeyboardEvent) => {
if (e.key === "ArrowLeft" && value > 0) {
onChange(value - 1);
onChange(value - step);
}
if (e.key === "ArrowRight" && value < 100) {
onChange(value + 1);
onChange(value + step);
}
};

Expand All @@ -26,7 +27,7 @@ export function ReactInputSliderWrapper({ value, onChange }: Props) {
onKeyUp={handleKeyboard}
onClick={() => rootRef.current?.focus()}
>
<Slider axis="x" xstep={0.1} x={value} onChange={({ x }) => onChange(x)} />
<Slider axis="x" xstep={step} x={value} onChange={({ x }) => onChange(x)} />
</span>
);
}

0 comments on commit bce8fca

Please sign in to comment.