mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 06:55:07 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user