zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
892 stars 231 forks source link

Thumb size/offset does not take in account the border of the thumb #152

Closed hugomassing closed 4 years ago

hugomassing commented 4 years ago

Hello,

when I'm adding a 1px border to the thumb, the calculated offset if the thumb only taking the width value without the border.

gist exemple : https://gist.github.com/hugomassing/156eef503df8ba7d1a087eb36353de03

stonebk commented 4 years ago

I think you just need box-sizing: border-box:

 const StyledThumb = styled.div`
+  box-sizing: border-box;
   height: 16px;
   width: 16px;
   background-color: #FFF;
   border: solid 1px #e5e7eb;
   border-radius: 50%;
   cursor: pointer;
   top: -6px;
   :focus {
     outline: none;
   }
`;
hugomassing commented 4 years ago

@stonebk Hello, even with box-sizing: border-box, thumbSize is not taking into account the border. Only solution I found is to substract the my border*2 to the width of the Slider.

stonebk commented 4 years ago

@hugomassing here is your code in a codesandbox: https://codesandbox.io/s/elated-bush-xzjv6

Can you update that example to make it more clear what the issue is you are having?

hugomassing commented 4 years ago

@stonebk I've updated my exemple. It happens when using the slider in a fixed width div, i.e. a modal. I've included the "hack" fix I use. You can see the overflow: scroll is making the slider scroll horizontally. https://codesandbox.io/s/clever-frog-eyj3p

Hope it's clearer for you! sorry for my first explanation.

stonebk commented 4 years ago

Published in react-slider@1.0.2

hugomassing commented 4 years ago

Thank you so much!