body-scroll-lock icon indicating copy to clipboard operation
body-scroll-lock copied to clipboard

Doesn't work on iOS mobile devices

Open dancherb opened this issue 3 years ago • 13 comments

Works great on desktop browsers and the mobile device view in Chrome's dev tools.

On iOS Safari, Chrome and Firefox, the body scroll locks but I'm unable to scroll in the modal opened by touching. Two-finger scroll seems possible but is buggy and also scrolls in the body element.

dancherb avatar Nov 11 '20 22:11 dancherb

Are you talking about the this demo?

diachedelic avatar Nov 12 '20 00:11 diachedelic

Have you got your target element set as the element that is meant to carry on scrolling? i.e. the element with overflow: auto

I was experiencing exactly the same issue you are and it was because I was accidentally targeting the parent element to the div actually doing the scrolling.

gauthierblanpain avatar Nov 18 '20 15:11 gauthierblanpain

Are you talking about the this demo?

Exactly this demo doesn't work on iOS 14.2. Once you first scroll down a bit to hide the bottom safari navigation bar and then open the modal, one can still scroll the body.

fresswolf avatar Dec 04 '20 16:12 fresswolf

could you have a look at this pull request and see if that solves your problem? https://github.com/willmcpo/body-scroll-lock/pull/207

jvitela avatar Dec 14 '20 08:12 jvitela

Works great on desktop browsers and the mobile device view in Chrome's dev tools.

On iOS Safari, Chrome and Firefox, the body scroll locks but I'm unable to scroll in the modal opened by touching. Two-finger scroll seems possible but is buggy and also scrolls in the body element.

Hellow, I have the same problem. Please, can you say how did you fixed this.

snowsergo avatar Dec 07 '21 13:12 snowsergo

Hi, @snowsergo please make sure you are testing with the branch from this pull request: https://github.com/willmcpo/body-scroll-lock/pull/229. That branch contains the latest fixes which are not yet merged to the main branch.

jvitela avatar Dec 08 '21 08:12 jvitela

To enable scrolling of target elements on iOS, you need to enable it in options.

disableBodyScroll(currentReference, { allowTouchMove: () => true });

charkour avatar Mar 10 '22 14:03 charkour

@charkour This works at the expense of re-enabling body scroll behind the modal it seems

bradleykhan avatar May 12 '22 11:05 bradleykhan

@bradleykhan, yeah you're right. This package is a little buggy and it appears to be no longer maintained. My team is looking for a better solution but this is the best we've found for now.

Thanks for your comment!

charkour avatar May 12 '22 11:05 charkour

@charkour Did you try https://github.com/tuax/tua-body-scroll-lock?

diachedelic avatar May 13 '22 00:05 diachedelic

@diachedelic, hi!

Yeah, we initially tried that too but ran into issues when trying to use multiple locks. Didn't try too long. Seemed to work better than this package in more cases so it's worth a shot in my opinion!

charkour avatar May 13 '22 02:05 charkour

@bradleykhan,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.

rick-liruixin avatar Apr 15 '23 07:04 rick-liruixin

在桌面浏览器和 Chrome 开发工具中的移动设备视图上运行良好。 在 iOS Safari、Chrome 和 Firefox 上,主体滚动锁定,但我无法在通过触摸打开的模式中滚动。双指滚动似乎是可能的,但有问题,并且还会在 body 元素中滚动。

你好,我有同样的问题。拜托,你能说说你是怎么解决这个问题的吗? 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 log, Refer to the releases page.

rick-liruixin avatar Apr 15 '23 07:04 rick-liruixin