Skip to content

Commit

Permalink
Fix thumb positioning issue on web for non-step sliders (#567) (#568)
Browse files Browse the repository at this point in the history
Co-authored-by: Bartosz Klonowski <[email protected]>
  • Loading branch information
landabaso and BartoszKlonowski authored Feb 9, 2024
1 parent 463a031 commit 7e81a3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions package/src/RNCSliderNativeComponent.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,18 @@ 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);
const lowerValue = minimumValue < lowerLimit ? lowerLimit : minimumValue;
const upperValue = maximumValue > upperLimit ? upperLimit : maximumValue;

Expand Down

0 comments on commit 7e81a3b

Please sign in to comment.