I have a really big bug on the iphone, that makes a page unusable and I just can't solve it. I can't find any topic about this issue as well.
I have the following screen:
In the middle, there is a div, which is set on -webkit-overflow: auto;
to have smooth scrolling inside this div. The scrolling is working absolutely fine and smooth.
BUT only until I do a touchmove
on another element outside of this div. If I do this and try to scroll the scrollcontainer again, it's frozen and not moving at all. After I tap around a few times on the scroll container it's scrolling again.
It's losing the scroll focus of the scroll container and trying to scroll a parent.
So, if I do a movement like this:
This looks like this :
Note: I'm just doing one touchmove from the bottom container into the overflow div. After releasing the finger and then trying to scroll again, it still scrolls the parent div.
I made a short example, so you can have a look with your iphone/phone here.
This issue only appears when using -webkit-overflow: auto
With normal overflow: scroll
it's always working but yes... you know how laggy this scrolling feels.
Is there any way to force the scroll focus in the desired container, when you're clicking/tapping a container with -overflow-scrolling: touch;
?
Disabling scroll with only CSS. There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.
Open the Settings app and go to the Devices group of settings. Go to the Touchpad tab. Scroll down to the Zoom and Scroll section, and uncheck the 'Drag two fingers to scroll' option. This will disable scrolling on the touchpad.
The touch-action CSS property specifies whether, and in what ways, a given region can be manipulated by the user (for instance, by panning or zooming). auto: The user agent may determine any permitted touch behaviors, such as panning and zooming manipulations of the viewport, for touches that begin on the element.
The iOS Safari Browser never really gives you full control over the scrolling. However there is a "hack" you can use, it requires JS tho:
position: fixed
on body,html
touchmove
occurs, set the body.scrollTop = 0
So in your case add:CSS
body, html {
margin: 0;
position: fixed;
}
JS
document.addEventListener('touchmove',function (){
document.body.scrollTop = 0
})
Example page for testing on device
Btw, a better way for handling this would be to make the headline/controls fixed and add a padding to the scrollcontainer. This wouldnt require any JS. try it
I too had this issue, my website worked fine on android phones, but on ios, i had to tap few times, to activate scroll.
I tried disabling body scroll, even tried this
-webkit-overflow-scrolling: touch; /* Lets it scroll lazy */
-webkit-overflow-scrolling: auto; /* Stops scrolling immediately */
I had to use custom scrollbar plugin mCustomScrollbar
This plugin completely overrides the system scroll. Here javascript controls the positioning of the scroll content. It makes the content position:relative
and uses top
to scroll the content.
If this plugin doesn't work for you, you can try any other scroll plugin. They all work the same way.
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