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(overlay): tour position offset in tour.taro #2631

Merged
merged 8 commits into from
Oct 18, 2024

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Oct 10, 2024

官网Tour.taro的demo:

image

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进

Summary by CodeRabbit

Summary by CodeRabbit

  • 新特性
    • 改进了覆盖组件的样式和动画效果,增强了用户体验。
    • 添加了覆盖过渡的动画关键帧,支持渐显和渐隐效果。
    • 调整了右到左(RTL)布局的样式,确保正确对齐。
  • 样式
    • 更新了 .nut-overlay.nut-overflow-hidden 类的样式规则,优化了溢出处理。
    • 修改了 Tour 组件的可见性处理逻辑,提升了位置计算的准确性。

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.88%. Comparing base (efaa3fa) to head (f9ccb7c).
Report is 4 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2631   +/-   ##
=======================================
  Coverage   83.88%   83.88%           
=======================================
  Files         218      218           
  Lines       17888    17888           
  Branches     2609     2609           
=======================================
  Hits        15006    15006           
  Misses       2877     2877           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

coderabbitai bot commented Oct 10, 2024

Walkthrough

此次更改主要涉及对 overlay.scss 文件中 .nut-overlay.nut-overflow-hidden.nut-overlay-slide 类的样式规则进行修改。.nut-overlay 类的定位和尺寸保持不变,背景和 z-index 属性由变量定义。同时,针对右到左(RTL)布局进行了调整,确保 .nut-overlay 类的对齐方式正确。此外,.nut-overflow-hidden 类的溢出属性由 overflow: hidden !important; 改为移除,显著改变了溢出管理方式。最后,为 .nut-overlay-slide 类引入了淡入和淡出的动画关键帧,增强了覆盖组件的样式和动画能力。

Changes

文件路径 更改摘要
src/packages/overlay/overlay.scss 修改了 .nut-overlay.nut-overflow-hidden.nut-overlay-slide 类的样式,添加了动画关键帧,调整了 RTL 布局样式,改变了溢出处理方式。
src/packages/tour/tour.taro.tsx 修改了 Tour 组件中的 useEffect 钩子,延迟调用 getRootPosition() 函数以确保状态更新完成。

Suggested reviewers

  • oasis-cloud

在草地上跳跃的小兔,
样式变化真是妙不可言。
动画流畅如春风,
RTL 布局更是贴心。
让我们一起欢呼雀跃,
兔子们的快乐无比! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a7ec5a4 and 9640650.

📒 Files selected for processing (1)
  • src/packages/overlay/overlay.scss (0 hunks)
💤 Files with no reviewable changes (1)
  • src/packages/overlay/overlay.scss

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c7256f0 and a7ec5a4.

📒 Files selected for processing (2)
  • src/packages/overlay/overlay.scss (0 hunks)
  • src/packages/tour/tour.taro.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • src/packages/overlay/overlay.scss
🧰 Additional context used

Comment on lines 107 to 111
if (visible) {
setTimeout(() => {
getRootPosition()
})
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

使用 setTimeout 可能会影响性能和用户体验

getRootPosition() 包装在 setTimeout 中可以确保在计算根位置之前组件的可见性状态更新已完全处理。然而,这种方法也有一些潜在的问题:

  1. 引入了不必要的延迟,可能会影响用户体验。
  2. 没有指定超时时间,可能导致不一致的行为。
  3. 缺少错误处理机制。

建议考虑以下改进:

  1. 使用 requestAnimationFrame 代替 setTimeout,以确保在下一次重绘之前执行。
  2. 添加错误处理和超时机制。
  3. 考虑使用 React 的 useLayoutEffect 钩子,它会在所有 DOM 变化之后同步触发。

示例改进:

useEffect(() => {
  setActive(0)
  setShowTour(visible)
  setShowPopup(visible)

  if (visible) {
    const rafId = requestAnimationFrame(() => {
      try {
        getRootPosition()
      } catch (error) {
        console.error('Failed to get root position:', error)
      }
    })
    return () => cancelAnimationFrame(rafId)
  }
}, [visible])

这个方案可以在保持原有功能的同时,提高性能和可靠性。

Copy link
Collaborator

@oasis-cloud oasis-cloud left a comment

Choose a reason for hiding this comment

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

setTimeout 实现的方案不具备扩展性。可考虑在 overlay 组件中增加展示后的回调属性。例如名称为:afterShow,类型为 () => void。

afterShow 是在 overlay 完全展示后触发。

@Alex-huxiyang
Copy link
Collaborator Author

e57cb59

@oasis-cloud oasis-cloud merged commit ed4654e into jdf2e:next Oct 18, 2024
5 checks passed
xiaoyatong pushed a commit that referenced this pull request Oct 25, 2024
* fix(overlay): move in taro

* chore: save

* chore: save

* chore: save
@Alex-huxiyang Alex-huxiyang deleted the hxy/pickerOption/1009 branch November 19, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tour 在页面有滚动条的情况下打开无滚动条的遮罩会导致错位偏移
2 participants