Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS5 - overflow scrolling horizontally is controlled by vertical touch [duplicate]

I have an HTML page with a fixed-height div which should be scrollable (only vertically). In iOS 5 this can be achieved using:

overflow-y: auto;
-webkit-overflow-scrolling: touch;

The div contains an unordered list with about 10 items.

The scrolling works, but sometimes it scrolls only if I swipe my finger diagonally or even horizontally and not vertically as it should be.

I'm wondering if anyone has encountered this issue. I don't want to think that it is a bug in iOS5, but I can't figure out what I'm doing wrong because most of the time it works fine.

like image 535
SzilardD Avatar asked Nov 03 '11 09:11

SzilardD


People also ask

What is webkit overflow scrolling touch?

In iOS, when an element inside an element with -webkit-overflow-scrolling: touch set is positioned absolutely (or fixed ) relative to an element outside of the scrolling container, the element is rendered only once and the rendering is not updated as the element is scrolled.

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 we fix the webkit overflow scrolling touch bug iOS?

The solution I found was to remove all the CSS that tricks the browser into using the GPU: -webkit-transform: translateZ(0px); -webkit-transform: translate3d(0,0,0); -webkit-perspective: 1000; By doing this, the '-webkit-overflow-scrolling: touch;' can still be included and still function as normal.

Can I use webkit overflow scrolling?

This means that you cannot use webkit-overflow-scrolling:touch in PhoneGap apps, and for most other use cases at this time. Instead you can use overflow: scroll, but that's only supported in Android 3.0+, so use iScroll, or the many other alternatives out there.


4 Answers

I had exactly the same issue. The problem turned out to be caused by two zero size iframes my site used to track history changes and load scripts. Removing these fixed the issue. I filed a bug with apple, waiting to hear back from them.

Check to see if you have any iframes on your page they could be the cause.

like image 68
paul stockley Avatar answered Oct 02 '22 02:10

paul stockley


I have found a hacky solution but it needs javascript...

I stumbled upon that problem while loading scrollable nodes via ajax and appending them with js.

I found out that resetting the -webkit-overflow-scrolling property with js saved the day

JS CODE:

var myDiv = $('.myDiv');
myDiv.css('-webkit-overflow-scrolling','auto');
function fn(){
    myDiv.css('-webkit-overflow-scrolling','touch');
}
setTimeout(fn,500);

It really sucks that we have to call the setTimeout method but that's the only way I could think of...

EDIT : Watch out for display:none

Webkit overflow scrolling touch CSS bug on iPad

like image 22
Armel Larcier Avatar answered Oct 02 '22 01:10

Armel Larcier


You need to put this css setting in your css file - the one you load using the content_css configuration variable:

body {
    -webkit-transform: translate3d(0, 0, 0);
}

The other option is to set the css directly from code on tinymce initialization:

$(tinymce.activeEditor.getBody()).css('-webkit-transform', translate3d(0, 0, 0));
like image 42
Thariama Avatar answered Oct 02 '22 01:10

Thariama


I had the same problem in iOS 5.1.1 and it turned out to be due to an ::after pseudo-element with position: fixed that was on an element that contained the scrollable list exhibiting the "wrong scroll axis" behavior. Details here.

like image 42
lazd Avatar answered Oct 02 '22 03:10

lazd