You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
754 B

2 months ago
  1. // @flow
  2. import getBoundingClientRect from './getBoundingClientRect';
  3. import getDocumentElement from './getDocumentElement';
  4. import getWindowScroll from './getWindowScroll';
  5. export default function getWindowScrollBarX(element: Element): number {
  6. // If <html> has a CSS width greater than the viewport, then this will be
  7. // incorrect for RTL.
  8. // Popper 1 is broken in this case and never had a bug report so let's assume
  9. // it's not an issue. I don't think anyone ever specifies width on <html>
  10. // anyway.
  11. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  12. // this (e.g. Edge 2019, IE11, Safari)
  13. return (
  14. getBoundingClientRect(getDocumentElement(element)).left +
  15. getWindowScroll(element).scrollLeft
  16. );
  17. }