Shopee / shopee-react-knowledgeable

⚛︎ To share knowledge and have fun.
78 stars 19 forks source link

Finding Scrollbar Width #188

Closed wgao19 closed 4 years ago

wgao19 commented 4 years ago

Here are two components centered with two different methods, one respects the scrollbar width, the other doesn't. Demo here: https://codepen.io/wgao19/pen/xxGJrNy

image

The two components are from two features maintained by different groups of people. So we should treat the two implementation details as black box.

BUTTTTTT, we need to make sure they align. So we need to offset one of them with scrollbar width.

Then we found a geeky hack from Brian Vaugh's code: https://github.com/bvaughn/react-window/blob/master/src/domHelpers.js#L6