fix: h5环境previewImage左右滑动时触发浏览器前进、后退 #5107
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
这个 PR 做了什么? (简要描述所做更改)
场景:H5 环境下,使用
Taro.previewImage()
进行图片预览时,左右滑动会触发浏览器前进、后退功能,譬如当滑动到第一页时,继续右滑会导致浏览器返回上一页。常发生于 UC浏览器 及 Android自带浏览器(如OPPO的ColorOS等)。修复:首先通过给预览图片容器
WrapViewr
添加 css 样式touch-action: none;
禁止浏览的触摸交互功能,此方法亦可消除chrom
使用preventDefault
时报错,此时可消除左右滑动时导致的浏览器返回问题。另,实测此方法在UC浏览器IOS版
不能达到预期效果,此时需在ImageContainer
中的处理touch
相关事件时开启preventDefault
及stopPropagation
方法阻止事件的传递。这个 PR 是什么类型? (至少选择一个)
这个 PR 满足以下需求:
这个 PR 涉及以下平台:
其它需要 Reviewer 或社区知晓的内容: