Hiding scroll bars...
Hi all! So I've got a requirement to hide unnecessary scroll bars and only show necessary scroll bars on hover. I can't easily change this requirement, so I'm trying to address it in an embedded UI Grid. By applying some css overrides, I can get it working in most places, but if I have a pinned column, the sizing math is off by 20px because it's assuming space for a scroll bar. E.g., scrolling to the bottom of the body does not quite get to the bottom of the pinned column and the last cell is truncated by 21px.
I have 2 ui-grid-viewports: ui-grid-render-container-left (pinned col) height: 197px; (smaller because overflow=hidden and it assumes its partner on the body will have a horizontal scroll) and ui-grid-render-container-body (other cols) height: 218px;
This works fine when overflow on the body = scroll, but problem starts after I override it with .ui-grid-viewport:hover { overflow: auto!important; -ms-overflow-style: auto; } .ui-grid-viewport { overflow: hidden!important; -ms-overflow-style: -ms-autohiding-scrollbar; -webkit-overflow-scrolling: touch; }
Anyone else trying similar? Any ideas for fixing? I was hoping I could add 21px of padding on the body whenever the scroll wasn't there, but that doesn't actually push the content up :(. I'm kind of thinking I'm just stuck here, but happy to hear ideas from anyone and I'll create a plunkr if anyone is interested in helping out!
Thanks!
This is why we don't have scrollbars as needed option. The layout must know if a scrollbar is present or not for all the offset calculations. The only way to do that is ask the DOM if a scroll bar is displayed. The code isn't pretty and I didn't want to implement it because of unknown side effects.
WHEN_NEEDED option is now present as part of ui-grid version 4.4.2