Skip to content

fix(h5): settle interrupted page scrolls - #19618

Merged
Single-Dancer merged 1 commit into
NervJS:mainfrom
Jarvis636431:codex/h5-page-scroll-interruption
Nov 10, 2026
Merged

Single-Dancer merged 1 commit into
NervJS:mainfrom
Jarvis636431:codex/h5-page-scroll-interruption

Conversation

@Jarvis636431

@Jarvis636431 Jarvis636431 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #19617

这个 PR 做了什么?

按 Window 或页面容器记录正在运行的滚动。同一目标上的新调用取消前一个动画,并通过现有 MethodHandler.fail 结算被替代的调用。新的零时长滚动也会取消旧动画,不同容器可各自完成滚动。

失败或完成回调存在时沿用现有回调与 Promise 约定。只使用 Promise 时,被中断的调用以 pageScrollTo:fail interrupted by another scroll 拒绝。取消回调同步发起新滚动时,最后发起的调用生效。

这个 PR 是什么类型?

  • 错误修复 (Bugfix)

这个 PR 涉及以下平台?

  • Web 端(H5)

验证

  • 9 个回归用例在原实现上均失败,修复后均通过。覆盖即时与动画滚动、回调次数、Promise 拒绝、取消回调内发起新滚动,以及独立的页面容器。
  • H5 全包 Jest 测试 36 个套件、372 个用例通过。改动文件 ESLint、Git 空白检查及 H5 生产构建通过。
  • 构建仍有已有的 previewImage / Swiper 类型告警及 Sass 弃用告警。验证使用 Jest/JSDOM。

Summary by CodeRabbit

  • Bug 修复
    • 同一页面目标启动新的滚动时,旧滚动会以中断错误结束;配置回调时,失败和完成回调各触发一次,不触发成功回调。未配置失败回调时,Promise 会被拒绝。
    • 非窗口滚动模式下,不同页面容器的滚动动画可独立完成。

@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b245969-9e70-4e10-ac2c-a600153e07e8
Commits

Reviewing files that changed from the base of the PR and between d697f3a and 6b006cc.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

pageScrollTo 现在按滚动目标跟踪活动动画。同一目标上的新滚动会中断旧滚动,并报告失败结果。新增测试覆盖 Promise 与回调结算,以及不同页面容器的滚动。

Changes

滚动中断与结算

层 / 文件 摘要
统一失败处理
packages/taro-h5/src/api/ui/scroll/index.ts
新增 failScroll,用于处理失败回调和 Promise 拒绝。缺少滚动参数或外层处理发生异常时,也会通过该函数报告失败。
目标级动画接管与验证
packages/taro-h5/src/api/ui/scroll/index.ts, packages/taro-h5/__tests__/ui/scroll.test.ts
活动滚动按目标分别登记。同目标的新滚动会中断旧滚动;滚动帧会检查活动状态,并在成功或出错时清除活动记录。测试覆盖中断结果、回调次数、回调中启动新滚动,以及不同页面容器的滚动。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • NervJS/taro#19584:该 PR 修复 pageScrollTo 动画越过目标的问题;本次 PR 处理连续调用时的中断与结果结算。

Suggested reviewers: zakarycode

Merge Risk: Minimal · previous review d697f

The change makes interrupted H5 page scrolls settle once and lets a new scroll on the same target take over. The supplied evidence shows no concrete merge-blocking risk.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确概括了 H5 中断页面滚动时完成原调用的主要变更。
Linked Issues check Passed [#19617] pageScrollTo 按滚动目标跟踪活动动画。新调用会取消同一目标的旧动画,并通过 MethodHandler.fail 结算旧调用。零时长调用也会取消旧动画,不同页面容器互不干扰。回归测试覆盖即时和动画滚动、回调次数、Promise 拒绝、取消回调中的新调用及独立容器。
Out of Scope Changes check Passed [#19617] 实现变更和回归测试均服务于滚动中断、结算或容器隔离。统一失败处理用于结算中断和其他错误。未发现无关变更。
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

兔子看滚动,轻敲小鼓点
新动画接棒,旧动画说再见
失败回调到,Promise 也结算
页面各自滚,不争同一站
月光下,目标位置稳稳停

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 284060cc-08c1-47bb-b6e7-f7a6debf275a
Commits

Reviewing files that changed from the base of the PR and between 4cee413 and d697f3a.

Files selected for processing: 2

  • packages/taro-h5/__tests__/ui/scroll.test.ts
  • packages/taro-h5/src/api/ui/scroll/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai
coderabbitai Bot requested a review from ZakaryCode November 7, 2026 16:01
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.51%. Comparing base (23d9147) to head (6b006cc).

Files with missing lines Patch % Lines
packages/taro-h5/src/api/ui/scroll/index.ts 77.77% 6 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #19618      +/-   ##
==========================================
+ Coverage   58.49%   58.51%   +0.01%     
==========================================
  Files         470      470              
  Lines       26045    26062      +17     
  Branches     6527     6494      -33     
==========================================
+ Hits        15236    15250      +14     
- Misses       8890     8935      +45     
+ Partials     1919     1877      -42     
Flag Coverage Δ
taro-cli 59.69% <ø> (ø)
taro-runtime 66.45% <ø> (ø)
taro-web 71.24% <77.77%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/taro-h5/src/api/ui/scroll/index.ts 88.23% <77.77%> (-1.97%) ⬇️

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Single-Dancer Single-Dancer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Single-Dancer Single-Dancer added this to the 4.3.3 milestone Nov 10, 2026
@Single-Dancer
Single-Dancer force-pushed the codex/h5-page-scroll-interruption branch from d697f3a to 6b006cc Compare November 10, 2026 09:51
@Single-Dancer
Single-Dancer merged commit 758a98c into NervJS:main Nov 10, 2026
23 of 25 checks passed
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.

[Bug]: H5 pageScrollTo 连续调用时前一次 Promise 无法结算

2 participants