-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-webkit-overflow-scrolling: touch does not "obey" z-index #14
Comments
Interesting. This sounds and looks similar to how touch devices vary in their bubbling of scroll events on elements in the page. Is your scroll region short enough to trigger a scroll? I wonder how it'll behave if it is... On Mar 27, 2012, at 9:19 PM, bridgestew wrote:
|
I don't understand your question about the scroll region being short enough. :) |
One workaround is to apply the same |
I think I ran into the same issue with my custom map component. I have a large pannable image (with -webkit-overflow-scrolling: touch) and absolutely positioned marker images on top. Sometimes I get one marker to show up, but usually they are hidden no matter what the z-index is. Any solutions yet for this? |
@kpuputti This bug's problem with z-index is only functional — visually the items are correct. You sure the map you've got has a lower z-index than all the markers? |
@moll Yes, the z-index on the map is lower than on the markers. I'm using Overthrow ( http://filamentgroup.github.com/Overthrow/ ) and the map works fine on Android 2.3 & 4.0, WP7, iOS 4.2. Of these platforms, at least Android 4.0 supports the native touch scrolling. This comment is the only info I've found: |
Oh, I found the solution. My problem seemed to be the same as in this issue: and the proposed workaround fixed the problem. |
This is not a bug; -webkit-overflow-scrolling: touch induces a stacking context. Just like if you put opacity: 0.9 or a 3d transform on the element. |
Thanks for chiming in with this info @hober. |
@hober How is this not a bug? I have my context layered properly and -webkit-overflow-scrolling: touch on the top most layer. Functionally everything works properly, except that the background scrolls instead of my modal, unless I use the scrollbar to scroll the div (which contains an unavoidable iFrame). Has anyone else found a workaround for this? |
Hello all, I am in the same boat here, unfortunately. But I did find a solution to this. Actually only one, for now. The solution that I've found is to turn off overflow for the DIV underneath (having lesser z-index) using "overflow:hidden". This seems to trick iOS into capturing the touch events on the top-most DIV (having a higher z-index). The only downside to this trick, however, is once the DIV having the higher z-index is dismissed (using animation or not), and "overflow:auto" or "overflow:scroll" is reapplied to the DIV underneath, a short "flick" is noticed as if the iOS is redrawing that DIV. If any of you guys or gals found a better solution, it'd be nice to share. /Noor |
Well, I consider the workaround I posted a year ago to be a better solution as it doesn't require JavaScript nor changes other elements' styles. |
I've seen and checked your proposed solution before. Surely, I had these CSS rules in place since I wanted the top DIV to have a scrollbar, even before I saw your post (it only made sense to me.) Now, the interesting thing is that although this works when the DIV is displayed without any animation, the solution doesn't work when animating the DIV (for example, making it appear by sliding it from the bottom of the screen to the top, like Safari's Bookmarks panel on the iPhone.) This must be a bug in iOS's transformations, I am guessing. Not opacity, as @hober suggested, since when I show the DIV instantly without an animation, and set its opacity to 0.9, scrolling still works. So we're back to the first post by @bridgestew since it doesn't work when the DIV is animated, sadly. /Noor |
And like I mentioned before, only setting overflow to hidden on the lower DIV makes the top DIV respond to touch scrolling (when the top DIV has been animated to its position.) |
Here's more information about a stacking context, introduced by @hober : |
@moll your trick works. Thanks! |
I stumbled onto this conversation because I have a similar issue that I have now fixed. I have a menu panel that is absolutely positioned above the main page. I hide/show this panel using an opacity transition. Both this panel and the main page use -webkit-overflow-scrolling:touch. My problem was that when showing the menu the scrolling would not work and instead the main page behind it would scroll. To fix this, I simply removed the -webkit-overflow-scrolling:touch from the menu when hidden and add it back when shown. It seems that the order in which this value is added is very important here. I was surprised to see that there is no flicker when you do this. Cheers |
@moll seems not working on ios7 |
This bug appears to be gone in iOS8. |
Still present on iOS 8.1. |
Like @iclanzan, I can confirm it is still present in iOS 8.1 Here's what I think is the relevant bug report on Webkit Bugzilla Edit: nope.
|
@noordawod |
Just target IOS device with media query and put overflow:touch; instead of -webkit-overflow-scrolling: touch; that works for me :-) |
Is there any working workaround for this issue? (The workaround from @moll does not work in my case, the one from @noordawod does, however while the short flicker is still acceptable, the repaint causes heavy performance problems which are far from acceptable) Two things I've noticed (testing with iPhone 5+6 on iOS 9.1 and 9.3.2): PS: why are the default bullet points bold and enormously large? Edit: I was able to reduce my project source to a rather comprehensible MCVE (check out this pen). To see the described behaviour you have to load the full-screen version (full) on a iOS device, save it to your home screen and call it from there. Then touch the yellow bar and try to scroll the list below. |
It seems that this issue (at least in some cases) does not occur when removing
from the CSS. This is not a suitable solution however, since those declarations are essential for percentage scale values to work. |
-webkit-overflow-scrolling: touch; overcomes z-index . and if we remove it then the scroll flickers. Is there any good solution of it? |
Yeah, do like I did years ago: ditch hybrid and go native. |
@gauravksoni Well. I choose to change some html structure to meet the demand.Becase of the mechanism of z-index. |
Wow, 5 years topic. I haven't been to this since yesterday, surprisingly its weird not to face with it. 3 hours of research i come up with, You should care all your segmented elements stack context |
workaround by me:
window.addEventListener('touchmove', (touchEvent) => {
/** touch scroll block */
const sBlock = '.rs-infinity-scroll-block';
const { target } = touchEvent;
if (target && target.closest && !(target.closest(sBlock))) {
touchEvent.preventDefault();
}
}, false); |
As many of you, I was led to this thread because of a common issue. In some cases our modal would seem locked in iOS Safari, and the body would retain the scroll touch events. From the developer console we could toggle the body's position:fixed style off and on, then the scroll would come back to our modal. This only seems to happen on some sites where our modal is triggered. We assume it must be some js or css library grabbing precedence. So we tried simulating the console method with this hack, using jQuery: $('body').css('position','').css('position','fixed'); That didn't work, so I set a timeout on the position reset. $('body').css('position','');
setTimeout(function(){$('body').css('position','fixed');},100); And that did it for us. Hacky? Yes! But it works well for us. I hope this may help someone else out there. We spent way too much time on this one :( |
Any solution for this scrolling issue. actually, I am investigating a solution for this. Issue happen only iPhone X and above. I need to stop scrolling the background part when the mobile menu is open. Its working in Android, iPhone 8...why happen only iPhone X and above I am using -webkit-overflow-scrolling: touch for scrolling in iPhone. |
I have been using the execllent body-scroll-lock library as a workaround for this issue. |
Summary:
-webkit-overflow-scrolling: touch does not "obey" z-index.
Platforms:
iOS5, not sure about other platforms
How to reproduce:
Reduced Example:
(Hastily thrown together example. No Media queries applied, so ignore the ugly -- just check out the bug.)
http://jsfiddle.net/cPHMN/48/embedded/result/
Bug Tracker ticket(s):
Workarounds:
The text was updated successfully, but these errors were encountered: