0

Is there a way in which it can be known if the user has forcefully hidden scrollBar in OS. In Mac there are option to control scrollBar visibility :

1. Automatically based on mouse or trackpad
2. Always
3. When scrolling

I need to control width of html element if scrollBar is visible, this can be easily done by grabbing target's height. But what if the user has set scrollBar to always hidden.

Is there a way in which we can get to know?

Gaurav Soni
  • 391
  • 1
  • 8
  • 26
  • I don't know if it answers your question, but you could compare offsetWidth and clientWidth to get the scrollbar width. Check out the first answer here: https://stackoverflow.com/questions/49305291/detect-if-scrollbar-is-visible-e-g-on-a-mobile-device – tdesero Feb 24 '21 at 08:20
  • @tdesero if i have set scroll bar to `Automatically based on mouse or trackpad` will the above solution give `0` ? – Gaurav Soni Feb 24 '21 at 08:24

1 Answers1

0

https://davidwalsh.name/detect-scrollbar-width

The solution for detecting width described in above link will do the math. If user has set scrollBar to be visible only while scrolling then it will give width as 0

Gaurav Soni
  • 391
  • 1
  • 8
  • 26