To setup an off-canvas menu I have to set the body to "overflow:hidden" to remove scrolling from the body and add it back in to a container around the content with "overflow-y:scroll". When I do this it seems to slow the scrolling on mobile specifically iOS devices.
Is there some sort of performance issue with moving the scrollbar from the body?
The difference For that, you need overflow: auto , which lets a browser automatically determine if a scroll bar is needed — or not. So in short: overflow: scroll : Always show a scroll bar. overflow: auto : Show a scroll bar when needed.
Use momentum-based scrolling, where the content continues to scroll for a while after finishing the scroll gesture and removing your finger from the touchscreen. The speed and duration of the continued scrolling is proportional to how vigorous the scroll gesture was. Also creates a new stacking context.
overflow: scrollSetting the value to scroll , the overflow is clipped and a scrollbar is added to scroll inside the box. Note that this will add a scrollbar both horizontally and vertically (even if you do not need it): You can use the overflow property when you want to have better control of the layout.
The most straightforward way for disabling scrolling on websites is to add overflow: hidden on the <body> tag.
Rather than a performance issue this is likely that your not seeing 'Momentum' scrolling on your iOS device
This can be solved by adding '-webkit-overflow-scrolling:touch' to your scrolling element i.e:
.scrolling-content { overflow-y: scroll; -webkit-overflow-scrolling: touch; height:100%; /*A value other than height:auto needs to be set*/ }
By default iOS devices use 'momentum' scrolling on the body but adding 'overflow-y:scroll' to an element does Not set a element to 'momentum' scrolling by default
See https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-overflow-scrolling for more info
Note: there's a number of Gotcha/Bugs with using -webkit-overflow-scrolling: touch on certain browsers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With