Modaal icon indicating copy to clipboard operation
Modaal copied to clipboard

Issue on iPhone with background_scroll

Open cbotman opened this issue 8 years ago • 5 comments

I'm not sure how widespread this issue is on mobiles but I've noticed a couple of related issues:

  • On iPhone 6, the background_scroll property is not having any affect. I.e. the background is scrollable even when set to false.
  • Related to that, it's possible to push the overlay out of the way, like in the screenshot (thanks @lee-karolczak).

img_0378

Experimenting with ideas here (http://stackoverflow.com/questions/9280258/prevent-body-scrolling-but-allow-overlay-scrolling) I was able to prevent the second issue (pushing the overlay), but the background was still scrolling.

I think fixing this might be a prerequisite to fixing #22 (scroll momentum on mobile).

cbotman avatar Apr 29 '16 07:04 cbotman

The issue with the background scrolling on iOS is a bug in the way the browser handles overflow: hidden on the body element. Applying it to the <html /> tag too will rectify this issue.

alexmccabe avatar May 16 '16 08:05 alexmccabe

Thanks Alex, we'll investigate it and work in a fix soon.

danhumaan avatar May 16 '16 08:05 danhumaan

I've spent some time this afternoon testing a variety of possible solutions to this one which only seem to trigger other undesirable side effects. See below for a list of solutions:

  1. Added overflow hidden to the html element as well as per @alexmccabe's suggestion. No change to background scrolling.
  2. Moving all styles for body overflow control into a class rather than directly inline, as well as applying that same class to the html element. No change to background scrolling.
  3. Based on a few stack overflow tickets there were some suggestions to add position relative to the body element with overflow hidden. Tried this with no change to background scrolling.
  4. Setting position fixed to body or html (never both at the same time) got us the closest to resolving this, and in fact did resolve this by stopping both the background scrolling and pushing over the overlay. The side effect however was that, no matter how far down the page you were scrolled before opening a modal, when you did open a modal the main body jumped all the way back to the top of the page in the background, meaning when you close the modal you're left at the start of the page again. This bug in my opinion isn't an acceptable side effect, as it may only create more frustration for the user by forcing them to have to find there way back to where they were before opening the modal.

If we had to make a decision between the existing and above implementations, I would be inclined to lean toward leaving the background scrolling as is, despite the overflow hidden's, as it retains their overall position in the page on close versus forcing the user to scroll back to the content where they opened the modal from.

But with that said, we are getting close to a solution that we may be able to work in to get the ideal outcome, so it's worth keeping this ticket open for the time being.

danhumaan avatar May 19 '16 07:05 danhumaan

Hi, I don't know if you found a solution (I guess not), but as far as for us it is not so 'bad' –it is, but not critical– to go up to the beginning of the page, just adding a fixed position, hidden overflow and with 100% to the html when opening, and removing or setting back to its default (targetting iOS devices) make us the deal.

victorbonilla avatar Jul 19 '17 07:07 victorbonilla

If this is still an issue, I came up with a solution that actually works across all devices. It's not perfect (emulating mobile devices in Chrome, then using the mousewheel to scroll causes some jittering), but other than that it works pretty well.

https://github.com/alexmccabe/framework/blob/master/src/js/core/Scroll.js

alexmccabe avatar Jul 20 '17 10:07 alexmccabe