Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrolling slow on mobile/ios when using overflow:Scroll

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?

like image 400
grasesed Avatar asked Nov 09 '15 01:11

grasesed


People also ask

What is the difference between overflow auto and scroll?

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.

What is momentum scrolling?

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.

How does overflow scrolling work?

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.

How do I turn off scrolling on Iphone CSS?

The most straightforward way for disabling scrolling on websites is to add overflow: hidden on the <body> tag.


1 Answers

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

like image 79
sjm Avatar answered Sep 23 '22 11:09

sjm