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: 🐛 修复 FloadingPanel 设置 height 不生效的问题 #725

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

Moonofweisheng
Copy link
Owner

@Moonofweisheng Moonofweisheng commented Nov 21, 2024

Closes: #703

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

#703

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新功能

    • 引入了新的 WdFloatingPanel 组件,允许在 Vue 应用中全局使用,无需逐个导入。
    • 组件的高度管理进行了优化,增加了 heightValue 以改善高度更新的逻辑。
  • 改进

    • 更新了高度更新逻辑,确保通过新的 updateHeight 方法进行一致的管理。

Copy link

vercel bot commented Nov 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 5:34am

Copy link

coderabbitai bot commented Nov 21, 2024

Walkthrough

该拉取请求对wd-floating-panel组件进行了多项修改,主要集中在高度值的处理逻辑上。引入了一个新的响应式引用heightValue,替代了原有的height引用,并更新了相关的计算属性和事件处理程序。新增的updateHeight函数封装了更新heightValue和发出update:height事件的逻辑。此外,观察height.valuewatch函数被修改为观察props.height,以便在属性变化时更新heightValue。整体上,这些改动简化了高度管理的过程。

Changes

文件路径 更改摘要
src/uni_modules/wot-design-uni/components/wd-floating-panel/wd-floating-panel.vue 引入heightValue替代height,添加updateHeight函数,修改watch逻辑以观察props.height
src/uni_modules/wot-design-uni/global.d.ts GlobalComponents接口中添加WdFloatingPanel组件。

Assessment against linked issues

Objective Addressed Explanation
实现浮动面板自定义锚点功能,确保height实时更新 (#703)

Possibly related PRs

Poem

在浮动面板上跳跃,
高度调整不再愁,
新的逻辑轻松舞,
每个锚点都能留。
兔子欢呼声不断,
代码更清晰如流。 🐇✨


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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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

netlify bot commented Nov 21, 2024

Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit 7955045
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/673ec6310656330008d4ee46
😎 Deploy Preview https://deploy-preview-725--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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: 0

🧹 Outside diff range and nitpick comments (2)
src/uni_modules/wot-design-uni/components/wd-floating-panel/wd-floating-panel.vue (2)

80-80: 建议优化滚动区域的触摸处理!

触摸事件的处理逻辑已经改进,但建议考虑以下优化:

  1. 在滚动区域内容较长时,可能需要更精确地区分拖动面板和滚动内容的手势。
  2. 考虑添加一个小的阈值来避免意外的高度变化事件触发。

建议添加以下优化:

 const handleTouchMove = (event: TouchEvent) => {
   const target = event.currentTarget as any
   if (target.dataset.id == 'content') {
-    if (!props.contentDraggable) return
+    if (!props.contentDraggable || Math.abs(touch.deltaY.value) < 10) return
   }
   touch.touchMove(event)
   const moveY = touch.deltaY.value + startY
   updateHeight(-ease(moveY))
 }

Also applies to: 90-90, 95-98


118-121: 注意观察器的执行顺序!

监听逻辑的改进很好,但需要注意以下几点:

  1. props.height 的变化会触发 heightValue 的更新
  2. boundary 的变化会触发就近锚点的重新计算

建议添加适当的条件检查以避免不必要的更新:

 watch(
   () => props.height,
   (value) => {
+    if (value === heightValue.value) return
     heightValue.value = value
   }
 )

Also applies to: 127-127

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cd20581 and 7955045.

📒 Files selected for processing (2)
  • src/uni_modules/wot-design-uni/components/wd-floating-panel/wd-floating-panel.vue (4 hunks)
  • src/uni_modules/wot-design-uni/global.d.ts (1 hunks)
🔇 Additional comments (4)
src/uni_modules/wot-design-uni/components/wd-floating-panel/wd-floating-panel.vue (3)

48-49: 代码重构改进了高度值的管理!

新增的 heightValue ref 和 updateHeight 函数很好地解决了高度设置不生效的问题。这种集中式的状态管理方式使代码更加清晰和可维护。

Also applies to: 72-76


65-65: 转换样式现在正确响应高度变化!

rootStyle 中使用 heightValue 确保了面板位置能够正确响应高度的更新。


Line range hint 48-127: 验证修复方案的完整性

整体实现很好地解决了 FloatingPanel 高度设置不生效的问题。建议进行以下验证:

  1. 在不同尺寸的屏幕上测试面板的行为
  2. 验证多个锚点之间的切换是否平滑
  3. 确认在快速拖动时不会出现异常
✅ Verification successful

浮动面板组件实现验证完成

根据代码分析结果:

  1. wd-floating-panel 组件的实现是独立的,没有其他组件依赖它的高度计算逻辑
  2. 高度计算和过渡动画的实现方式是合理的,使用了 transform: translateY 配合 cubic-bezier 实现平滑过渡
  3. 组件具有完整的边界处理和阻尼效果,可以很好地处理快速拖动的情况

建议:

  • docs/component/floating-panel.md 中补充不同尺寸屏幕的适配说明
  • 添加多个锚点切换的示例代码
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 搜索其他可能受影响的组件
rg -l "wd-floating-panel" --type vue

# 检查是否有其他组件使用了类似的高度计算逻辑
ast-grep --pattern 'transform: `translateY(calc($$$))`'

Length of output: 122


Script:

#!/bin/bash
# 搜索包含 wd-floating-panel 的文件
rg -l "wd-floating-panel"

# 搜索使用 translateY 的相关代码
rg "transform.*translateY"

# 搜索其他可能使用类似高度计算逻辑的文件
rg "height.*value"

Length of output: 16450

src/uni_modules/wot-design-uni/global.d.ts (1)

94-94: 类型声明添加正确!

WdFloatingPanel 组件的类型声明遵循了以下规范:

  • 保持了与其他组件一致的命名规范
  • 正确引用了组件的默认导出
  • 符合全局组件注册的要求

这个改动将确保 FloatingPanel 组件在 TypeScript 环境下能够被正确识别和使用。

Copy link

Deploying wot-design-uni with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7955045
Status: ✅  Deploy successful!
Preview URL: https://9abcb548.wot-design-uni.pages.dev
Branch Preview URL: https://fix-floating-panel-height.wot-design-uni.pages.dev

View logs

@Moonofweisheng Moonofweisheng merged commit 3cc1805 into master Nov 21, 2024
7 checks passed
@Moonofweisheng Moonofweisheng deleted the fix/floating-panel-height branch November 21, 2024 06:38
@caisheng-0304
Copy link

什么时候更新到线上用,1.3.14还是不生效

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.

FloatingPanel 浮动面板自定义锚点功能,设置height不生效,每次都是取anchors[0]的值
2 participants