Merge pull request #293 from aoki/fix/slider-offset-bug

fix(slider): fix the bug causing offset is out of bounds
This commit is contained in:
witt
2020-06-28 16:59:52 +08:00
committed by GitHub

View File

@@ -107,7 +107,8 @@ const Slider: React.FC<React.PropsWithChildren<SliderProps>> = ({
if (disabled) return
const offset = event.currentX - event.startX
const currentOffset = offset + lastDargOffsetRef.current
setLastDargOffset(currentOffset)
const boundOffset = currentOffset < 0 ? 0 : Math.min(currentOffset, sideWidthRef.current)
setLastDargOffset(boundOffset)
}
const clickHandler = (event: React.MouseEvent<HTMLDivElement>) => {
if (disabled) return