Skip to content
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

Body scroll is not blocked on IOs #206

Open
alexanderKhvostov opened this issue Dec 3, 2020 · 18 comments
Open

Body scroll is not blocked on IOs #206

alexanderKhvostov opened this issue Dec 3, 2020 · 18 comments

Comments

@alexanderKhvostov
Copy link

Hi, sorry but it doesn't work :(
I still can sometime scroll body. Maybe Apple again has changed something?

Iphone 11pro IOs 13.6.
https://www.loom.com/share/9fe89fe098e64e64a26d5533f9921f29

@alexanderKhvostov alexanderKhvostov changed the title Body scroll is not blocked Body scroll is not blocked on IOs Dec 3, 2020
@jvitela
Copy link
Contributor

jvitela commented Dec 14, 2020

Hi, @alexanderKhvostov you have a look at this pull requests and see if it works for you:
#207

@horaklukas
Copy link

I experience the same issue at least on iOS 12 😕

The PR #207 is not helpful, settings overflow: hidden is not a solution.

@jvitela
Copy link
Contributor

jvitela commented Jan 24, 2021

Hi @horaklukas,

Can you please elaborate how did you test PR #207 ? Did you inspect the dom to make sure overflow: hidden was actually applied to the body element?

@yoonjaepark
Copy link

yoonjaepark commented Feb 10, 2021

Hi @jvitela

In some cases, the scroll has arrived at the bottom of the scroll element area. If there is a scroll in the content area, the scroll of the content moves.

<body>
  // scroll content
  <div>
  </div>
  // scroll popup element 
  <div>
  </div>
</body>

@arthurzhukovski
Copy link

arthurzhukovski commented Mar 12, 2021

@jvitela unfortunately this doesn't help. Since OP haven't provided much details I'd like to elaborate on when this bug might be seen.
There're two conditions required for this bug to happen:

  1. Safari's toolbar (which is located on the bottom of the screen) must be hidden
  2. User's finger must be placed on the bottom of the screen

If these two conditions are met and user starts scrolling, it will happen.

If finger is being put on any other place of the screen or when the toolbar is shown, everything works as expected.
I believe this bug is caused by some Safari internals and nothing can be done for now.

@chendong-xie
Copy link

chendong-xie commented Jun 15, 2021

@JonesTwink

hi,did you solve it?

@jvitela
Copy link
Contributor

jvitela commented Jun 15, 2021

Hi @chendong-xie and @JonesTwink,

Yes, my last change fixes this issue. Setting position:fixed forces the browser to display the toolbar and therefore there is no scrollable area.

Please do test the latest changes of the feature branch and confirm if it also works for you. The examples are updated so you don't need to rebuild it yourself.

@chendong-xie
Copy link

hi @jvitela this way looks ok, thank you for your reply.
when you plan to release this feature?

@jvitela
Copy link
Contributor

jvitela commented Jun 16, 2021

hi @chendong-xie,

when you plan to release this feature?

That question should be answered by @willmcpo

@n19htz
Copy link

n19htz commented Jul 27, 2021

Hi @chendong-xie and @JonesTwink,

Yes, my last change fixes this issue. Setting position:fixed forces the browser to display the toolbar and therefore there is no scrollable area.

Please do test the latest changes of the feature branch and confirm if it also works for you. The examples are updated so you don't need to rebuild it yourself.

if you solving it with position: fixed you gotta be aware of scroll reset, i e for example you clicking a button that opens modal and that button is at middle of document (i e scrollTop > 0). Than when you lock the scroll with forcing safari to show bottom bar (by setting position:fixed) your scroll is gonna reset (scrollTop === 0)

@jvitela
Copy link
Contributor

jvitela commented Jul 27, 2021

@n19htz
Copy link

n19htz commented Jul 27, 2021

@n19htz Do you mean this? https://github.com/jvitela/body-scroll-lock/blob/3b7877b77c997751ff484a5f89ca2eeb5fda1bed/src/bodyScrollLock.js#L120

yes, i've tried 4.0.0-beta version and scroll restoration does not work there

@jvitela
Copy link
Contributor

jvitela commented Jul 27, 2021

@n19htz Could you please provide a minimal reproducible example? or in case it happens with the included examples a video showing the issue would be great and please indicate the browser and OS versions.

@n19htz
Copy link

n19htz commented Jul 27, 2021

iOS 14.5

pro_blur-2lsb0vqgm6.mp4

@pawelbujna
Copy link

I have a quetion, will this fix also fix the problem with jumping layout when clicking on inputs inside modals? I know that position: fixed casues the bug it happens only on scrollable elements. To fix my case i had to completely hide the page contents and display only a modal. Feels like it could be part of this bug.

Example video:

Screen.Recording.2021-07-29.at.12.10.38.mov

@Trendymen
Copy link

Trendymen commented Aug 13, 2021

const { scrollY, scrollX, innerHeight } = window;
    document.body.style.position = 'fixed'; 
    document.body.style.top =  -scrollY;   //Mabye there and next line should be add + "px" in the end.
    document.body.style.left = -scrollX; 

@jvitela
Copy link
Contributor

jvitela commented Aug 13, 2021

Hi @Trendymen and @pawelbujna,

Please check #229

@rick-liruixin
Copy link

They stopped the repairs. I had to do it myself, in the same way, with a new version of typeScript. And fix these problems for everyone to use.

npm i body-scroll-lock-upgrade

repair Changelog
Refer to the releases page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants