fix(gesture): 修复鸿蒙下视频播放页横滑切换简介/评论区难以触发的问题 - #98
Merged
Conversation
根因:鸿蒙 embedding(`FlutterPage`)将 ArkUI PanGesture 默认的 5(vp) 作为 `physicalTouchSlop` 经 viewport metrics 下发,框架除以 DPR 后竖向滚动触发阈值仅约 1.5 逻辑像素(Android 约为 8)。竖向手势几乎瞬间赢得手势竞技场,横向手势(阈值 18~24)只有约 5° 以内的近乎纯水平滑动才能触发,单纯放宽横向判定无效。 - `main.dart`:鸿蒙下全局覆盖 MediaQuery `gestureSettings`,将竖向 touchSlop 恢复为 Android 水平的 8 逻辑像素 - `touchSlopH` 默认值 24→12:与竖向 8 形成约 34° 的主导方向分界(已自定义过该设置的用户不受默认值影响) - 横向方向判定由 `dx > 3·dy` 放宽为 `dx > dy`
wm-develop
added a commit
to wm-develop/PiliPlus
that referenced
this pull request
Jul 31, 2026
根因:dev4harmony#98 的修复由三部分组成,其中「鸿蒙下将竖向 touchSlop 覆盖为 8」这一项写在 `MyApp._scaledBuilder` 的 MediaQuery `copyWith` 参数里,两条分支各写了一份。跟进 2.1.0(1aebdefe3)时上游重写了 `uiScale == 1.0` 分支的整个 `copyWith`,该参数被静默丢弃;而手机上 uiScale 恒为 1.0,等于这条覆盖从未执行过。 竖向 slop 于是退回鸿蒙引擎下发的 ~1.48 逻辑像素(ArkUI PanGesture 的 5vp 被当作 physicalTouchSlop 下发,框架又除了一次 DPR),与横向的 12 形成约 8:1 的差距 —— 只有约 7° 以内近乎纯水平的滑动才抢得到手势竞技场。 另两项(touchSlopH 默认值 24→12、方向判定 dx > 3·dy → dx > dy)完好,但如 dev4harmony#98 所述,它们单独无法生效。 - 将 gestureSettings 覆盖上移到 if/else 之前,直接改写 mediaQuery 本身:该覆盖与 uiScale 无关,两条分支都应生效 - if/else 内部随之恢复为与上游逐字一致,后续再合上游只会产生冲突(吵闹、可见),不会再被静默覆盖
wm-develop
added a commit
to wm-develop/PiliPlus
that referenced
this pull request
Jul 31, 2026
## 原因 [dev4harmony#98](dev4harmony#98) 的修复由三部分组成,其中「鸿蒙下将竖向 touchSlop 覆盖为 8」这一项写在 `MyApp._scaledBuilder` 的 MediaQuery `copyWith` 参数里,两条分支各写了一份。跟进 2.1.0(1aebdefe3)时上游重写了 `uiScale == 1.0` 分支的整个 `copyWith`,该参数被静默丢弃;而手机上 uiScale 恒为 1.0,等于这条覆盖从未执行过。 竖向 slop 于是退回鸿蒙引擎下发的 ~1.48 逻辑像素(ArkUI PanGesture 的 5vp 被当作 physicalTouchSlop 下发,框架又除了一次 DPR),与横向的 12 形成约 8:1 的差距 —— 只有约 7° 以内近乎纯水平的滑动才抢得到手势竞技场。 另两项(touchSlopH 默认值 24→12、方向判定 dx > 3·dy → dx > dy)完好,但如 [dev4harmony#98](dev4harmony#98) 所述,它们单独无法生效。 ## 修复 - 将 gestureSettings 覆盖上移到 if/else 之前,直接改写 mediaQuery 本身:该覆盖与 uiScale 无关,两条分支都应生效 - if/else 内部随之恢复为与上游逐字一致,后续再合上游只会产生冲突(吵闹、可见),不会再被静默覆盖 - update pr_check.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
问题
视频页左右滑动切换"简介/评论"标签页极难触发,绝大多数滑动被竖向滚动截获,只有近乎纯水平的滑动偶尔成功。
原因
鸿蒙 Flutter embedding(
FlutterPage)把 ArkUI PanGesture 默认的5(vp) 当作physicalTouchSlop下发,框架除以 DPR 后竖向滚动的触发阈值仅约 1.5 逻辑像素(Android 约为 8)。竖向手势几乎瞬间赢得手势竞技场,横向手势(阈值 18~24)只有约 5° 以内的近乎纯水平滑动才能触发——单纯放宽横向判定无效。改动内容
main.dart:鸿蒙下全局覆盖 MediaQuerygestureSettings,把竖向 touchSlop 恢复为 Android 水平的 8 逻辑像素(列表滚动手感与 Android 一致)touchSlopH默认 24→12:与竖向 8 形成约 34° 的主导方向分界(用户自定义过的设置不受影响)dx > 3·dy放宽为dx > dy