Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using '-webkit-overflow-scrolling: touch' hides content while scrolling/dragging

as the title says I'm having the problem with content getting hidden while scrolling/dragging the content when using the CSS property -webkit-overflow-scrolling: touch.

For a basic understanding, here is my markup

<div class="page">
   <div class="section_title">Title</div>
   <div class="items">
      <div class="item">...Text and Image...</div>
      <div class="item">...Text and Image...</div>
      <div class="item">...Text and Image...</div>
   </div>
   <div class="section_title">Title</div>
   <div class="items">
      <div class="item">...Text and Image...</div>
      <div class="item">...Text and Image...</div>
      <div class="item">...Text and Image...</div>
   </div>
</div> 

And the CSS:

.page {
    width: 320px;
    height: 366px;
    overflow: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

The code itself works good, I can scroll through the content but everything that is inside of a items div get's hidden while I'm scrolling/dragging. Anyone came across this issue and solved it or is it just standard behavior of Mobile Safari to save memory and there is nothing we can do about it?

Any help is appreciated :-)

like image 413
Björn Kaiser Avatar asked Mar 21 '12 09:03

Björn Kaiser


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.

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.

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.

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.


1 Answers

Have you tried putting the elements into memory?

If not, try putting .items in memory using the css -webkit-transform: translate3d(0,0,0);

You may want to go higher or lower in the nesting depending on performance, ie applying the translate to .page or .item. This will increase the memory used which can get crashy but it helps the browser redraw everything.

Anyways, hope that helps!

like image 171
tuddy Avatar answered Sep 17 '22 13:09

tuddy