Search code examples
ios8webkitscrolloverlaygesture

iOS8 webkit-overflow-scrolling:touch with overlay


I currently have an app with UIWebView that has a scrollable div with the webkit-overflow-scrolling:touch property. When the side menu is open, I place an overlay (another div) on top of the content to give a dimming effect.

The problem is that when the menu is open (and the overlay in place) when the user pans, the scrollable div actually scrolls when the overlay should be stopping this form happening.

Now, in iOS7, the solution was to add the webkit-overflow-scrolling:touch; to the overlay. That works like a charm, but in iOS8 it doesn't.

Here is a link to an example of the problem. If run on iOS 7 it works as expected, if run on iOS 8 the content in the back will scroll.

.scrollable {
    width:100%;
    height:200px;
    -webkit-overflow-scrolling:touch;
    overflow:scroll;
}

.overlay {    
    position:absolute;
    width:100%;
    overflow:scroll;
    height:200px;
    -webkit-overflow-scrolling:touch;
    background-color:black;
    opacity:.5;
    transform: translate3d(0,0,0);
    -webkit-transform: translate3d(0,0,0); 
    z-index:10;
}

https://jsfiddle.net/SergioM/57f2da87/9/

I also tried setting the overflow-x property of the scrollable div to hidden/auto when the menu is opened but that adds a terrible flicker.

Any suggestion will be much appreciated.

Thanks.


Solution

  • Well after trying many different options I came up with a work around that is good enough for now.

    I added a div inside the overlay that is vertically 1% bigger. That now warranties that the event is handled by the overlay and not passed on to the container at the back. This also allows me to listen to events natively such as pan (horizontally), the vertical ones wont come up but that is ok for now.

    .overlayInner {
        color:red;
        height:101%;
        margin-left:30px;
    }
    

    here is a link to the fiddle.The margin is unnecessary, just to avoid the number to overlap.

    http://jsfiddle.net/SergioM/57f2da87/15/