From c2709b97b1106d8dcb230b1981e15b07e6964a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Landabaso=20D=C3=ADaz?= Date: Wed, 27 Dec 2023 15:53:58 +0100 Subject: [PATCH] Fix thumb positioning issue on web for non-step sliders (#567) --- package/src/RNCSliderNativeComponent.web.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package/src/RNCSliderNativeComponent.web.tsx b/package/src/RNCSliderNativeComponent.web.tsx index 67db17fc..141f7825 100644 --- a/package/src/RNCSliderNativeComponent.web.tsx +++ b/package/src/RNCSliderNativeComponent.web.tsx @@ -263,13 +263,17 @@ const RCTSliderWebComponent = React.forwardRef( }; const getValueFromNativeEvent = (pageX: number) => { - const {width = 1} = containerSize.current; + const adjustForThumbSize = (containerSize.current.width || 1) > thumbSize; + const width = + (containerSize.current.width || 1) - + (adjustForThumbSize ? thumbSize : 0); if (containerPositionInvalidated.current) { containerPositionInvalidated.current = false; updateContainerPositionX(); } - const containerX = containerPositionX.current; + const containerX = + containerPositionX.current + (adjustForThumbSize ? thumbSize / 2 : 0); if (pageX < containerX) { return inverted ? maximumValue : minimumValue;