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

fix: popup strict prevent default to fix with IOS12 #5738

Merged
merged 3 commits into from
Oct 17, 2022
Merged

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Oct 14, 2022

IOS 12 下横向滚动后再垂直滚动会被认为是合理的滚动方向(标准为初次滚动一个方向后就会被锁定,而非可以混合滚动),导致在开始 touchmove 没有调用 preventDefault 就会出现后期无法阻止滚动导致 Popup 锁不住屏幕滚动的问题。
添加一个 strict 模式,使用后直接锁定而不关心方向性。

不确定是否保险,请多关注一下。

@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Base: 89.91% // Head: 89.60% // Decreases project coverage by -0.31% ⚠️

Coverage data is based on head (a5dd2e2) compared to base (43a0c61).
Patch coverage: 9.09% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5738      +/-   ##
==========================================
- Coverage   89.91%   89.60%   -0.32%     
==========================================
  Files         297      297              
  Lines        6339     6370      +31     
  Branches     1554     1562       +8     
==========================================
+ Hits         5700     5708       +8     
- Misses        590      609      +19     
- Partials       49       53       +4     
Impacted Files Coverage Δ
src/utils/dev-log.ts 33.33% <5.88%> (-66.67%) ⬇️
src/utils/use-lock-scroll.ts 49.15% <6.66%> (-15.30%) ⬇️
src/components/popup/popup.tsx 84.74% <100.00%> (ø)
src/components/image-uploader/image-uploader.tsx 92.72% <0.00%> (+6.36%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link
Contributor

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5738.surge.sh

@github-actions
Copy link
Contributor

github-actions bot commented Oct 14, 2022

Size Change: +193 B (0%)

Total Size: 350 kB

Filename Size Change
./lib/bundle/antd-mobile.compatible.umd.js 188 kB +120 B (0%)
./lib/bundle/antd-mobile.umd.js 146 kB +73 B (0%)
ℹ️ View Unchanged
Filename Size
./lib/bundle/css-vars-patch.css 1.4 kB
./lib/bundle/style.css 14.6 kB

compressed-size-action

@@ -11,3 +11,28 @@ export function devError(component: string, message: string) {
console.error(`[antd-mobile: ${component}] ${message}`)
}
}

let infoBox: HTMLTextAreaElement
export function devPrint(...message: any[]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devPrint 的作用是啥?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来是直接在页面上打印出来信息……

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,这个工具方法用来在真机上调试数据。没有办法审查元素,就折中一下~

@@ -43,7 +43,7 @@ export const Popup: FC<PopupProps> = p => {
}, [props.visible])

const ref = useRef<HTMLDivElement>(null)
useLockScroll(ref, props.disableBodyScroll && active)
useLockScroll(ref, props.disableBodyScroll && active ? 'strict' : false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样改了之后,如果 Popup 里面存在滚动区域,是不是也会被禁止……?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

试了下确实会被禁止

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样改了之后,如果 Popup 里面存在滚动区域,是不是也会被禁止……?

Updated. 在 useLockScroll 里添加了滚动检查~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有一个 case……如果有一个可以滚动的 div,然后 Popup 渲染在了这个 div 里面( getContainernull ),这种情况下会触发 div 的滚动么

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个检测逻辑只看点击的实际元素是什么,只要这个点击元素上层有可以滚动的且不是 body 就允许滚动。

@zombieJ zombieJ merged commit 538c168 into master Oct 17, 2022
@zombieJ zombieJ deleted the fix-ios-12 branch October 17, 2022 02:29
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

Successfully merging this pull request may close these issues.

None yet

3 participants