-
Notifications
You must be signed in to change notification settings - Fork 287
feat: add ResetViewBox plugin #192
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @xxMudCloudxx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
原来Draft PR也会触发CI/CR |
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.
Code Review
本次PR引入了ResetViewBox插件,并重构了滚轮缩放功能以解决undo/redo栈污染问题,整体实现很棒。我发现了一些可以改进的地方,主要涉及事件负载的类型安全、代码可读性和魔法数的处理。具体建议请见评论。
|
/gemini review |
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.
Code Review
这个 PR 引入了 ResetViewBox 插件,并���构了滚轮缩放功能以解决 undo/redo 栈污染问题,做得很好。通过将缩放时的状态更新直接交由 state.updateOptions 处理,避免了为每一次缩放步长都创建命令,然后在缩放结束后(通过监听 keyup 事件)创建单个命令记录到历史记录中,这个实现非常巧妙。
不过,在 StateManager 的实现中存在一些问题。将自定义的 applyOptionUpdates 函数替换为 lodash.merge 导致了部分重要功能的回归,例如无法通过传入 undefined 来删除属性。此外,viewBox 和 padding 的更新逻辑也存在缺陷。我还对新的 ResetViewBox 插件的样式实现提出了一些改进建议。请查看具体的审查评论。
|
|
||
| updateOptions(options: UpdatableInfographicOptions) { | ||
| applyOptionUpdates(this.options, options); | ||
| merge(this.options, options); |
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.
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.
@Aarebecca 还需要 undefined 值视作删除属性这个业务逻辑吗?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #192 +/- ##
==========================================
+ Coverage 45.22% 45.55% +0.32%
==========================================
Files 334 334
Lines 26635 26790 +155
Branches 2115 2142 +27
==========================================
+ Hits 12046 12204 +158
+ Misses 14579 14576 -3
Partials 10 10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
功能
提供“重置视图”的UI插件。当用户对画布进行缩放(Zoom)或平移(Pan)操作导致视图发生变化时,该插件会在画布右下角显示一个浮动的重置按钮。点击该按钮可将视图恢复到最佳适配(Fit View)状态或初始状态。
功能特性
viewBox:change事件,仅在视图偏离初始状态时显示按钮。resize事件,自动调整初始状态基准和按钮位置。UpdateOptionsCommand,因此该操作支持撤销/重做(Undo/Redo)。配置项
stylePartial<CSSStyleDeclaration>classNamestringgetContainerHTMLElement | (() => HTMLElement)document.body。样式
默认样式包含在 constant
RESET_BUTTON_CLASS中,样式 ID 为RESET_BUTTON_STYLE_ID。自定义配置项使用示例
已解决的问题
TODO / Dependencies
预览