From 7612f7db138a95844da2a22d120025bdf8d6f5ee Mon Sep 17 00:00:00 2001 From: Lucas Bordeau <bordeau.lucas@gmail.com> Date: Fri, 18 Jun 2021 19:50:55 +0200 Subject: [PATCH] fix(range): fixed pushable prop typing --- src/Range.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Range.tsx b/src/Range.tsx index 2b3e4959f..3305cbdbd 100644 --- a/src/Range.tsx +++ b/src/Range.tsx @@ -39,7 +39,7 @@ export interface RangeProps extends GenericSliderProps { min?: number; max?: number; allowCross?: boolean; - pushable?: boolean; + pushable?: boolean | number; onChange?: (value: number[]) => void; onBeforeChange?: (value: number[]) => void; onAfterChange?: (value: number[]) => void; @@ -276,7 +276,10 @@ class Range extends React.Component<RangeProps, RangeState> { pos = props.reverse ? -pos : pos; const max = maxValue - Math.max(...startBounds); const min = minValue - Math.min(...startBounds); - const ratio = Math.min(Math.max(pos / (this.getSliderLength() / (maxValue - minValue)), min), max); + const ratio = Math.min( + Math.max(pos / (this.getSliderLength() / (maxValue - minValue)), min), + max, + ); const nextBounds = startBounds.map((v) => Math.floor(Math.max(Math.min(v + ratio, maxValue), minValue)), );