-
-
Notifications
You must be signed in to change notification settings - Fork 225
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: 弹出窗口因为浏览器窗口变化从bottomLeft对齐到topRight对齐时,箭头对齐错误 #491
Conversation
Walkthrough此次更改涉及 Changes
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 Files selected for processing (1)
src/hooks/useAlign.ts
(6 hunks)
🔇 Additional comments (5)
src/hooks/useAlign.ts (5)
326-327
: 引入临时变量以保存原始对齐点,提升代码可维护性
通过新增 tmpTargetPoints
和 tmpPopupPoints
变量,避免了在对齐计算过程中对原始对齐点的直接修改,提升了代码的清晰度和可维护性。
453-456
: 在翻转后更新临时对齐点,确保对齐计算准确
在对齐点翻转后,及时更新 tmpPopupPoints
和 tmpTargetPoints
,确保后续计算使用最新的对齐点信息,避免可能的逻辑错误。
500-503
: 处理顶部到底部的翻转,保持对齐逻辑一致性
在处理从顶部到底部的翻转时,更新了对齐点并调用了更新函数,保持了翻转逻辑的一致性和正确性。
554-557
: 增加左右翻转的处理,增强组件对不同情况的适应性
在左右翻转时,更新了对齐点并调用更新函数,确保弹出层在屏幕边缘情况下也能正确对齐。
601-604
: 完善从左到右的翻转逻辑,提升用户体验
通过处理从左到右的翻转,更新对齐点和临时变量,确保弹出层在各种对齐方式下都能正确显示,提高了组件的可靠性。
function updateTmpPopupPointsAndTmpTargetPoints() { | ||
tmpPopupPoints = splitPoints(nextAlignInfo.points[0]); | ||
tmpTargetPoints = splitPoints(nextAlignInfo.points[1]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
将更新临时对齐点的逻辑封装成函数,减少代码重复
新增的 updateTmpPopupPointsAndTmpTargetPoints()
函数封装了更新临时对齐点的逻辑,避免了重复代码,提高了代码的复用性和可读性。
react-component/picker#886 (comment)
Summary by CodeRabbit
新功能
修复