-
-
Notifications
You must be signed in to change notification settings - Fork 313
feat: add ebg fading #818
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: dev
Are you sure you want to change the base?
feat: add ebg fading #818
Conversation
Summary of ChangesHello @HardyNLee, 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! 此拉取请求为 WebGAL 应用程序引入了背景图片切换时的平滑淡入淡出过渡效果。通过在 HTML 中添加一个叠加层元素,并修改 JavaScript 函数来动画化该叠加层的透明度,从而实现从旧背景到新背景的视觉过渡。此功能已集成到现有的背景设置逻辑中,以提供更流畅的用户体验。 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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
|
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 旨在为 ebg(效果背景)切换背景图片时增加一个淡入淡出过渡效果。实现方式是在 HTML 中增加一个覆盖层元素,并通过 CSS 和 JavaScript 动画来控制新旧背景的交替。整体实现思路清晰,但有几处可以改进的地方,主要涉及 CSS 代码的重复和 TypeScript 模块中状态管理的方式,具体请看我的详细评论。
| .html-body__effect-background-overlay { | ||
| height: 100%; | ||
| width: 100%; | ||
| background-position: center; | ||
| background-repeat: no-repeat; | ||
| background-size: cover; | ||
| position: absolute; | ||
| top: 0; | ||
| left: 0; | ||
| background-color: black; | ||
| opacity: 0; | ||
| } |
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.
这个新的 CSS 类 .html-body__effect-background-overlay 与现有的 .html-body__effect-background 类(第 14-25 行)之间存在大量重复的样式属性,例如 background-position, background-repeat, background-size, position 等。
代码重复会增加未来维护的难度,当需要修改这些共享样式时,不得不在多个地方进行同步修改,容易出错。
为了遵循 DRY (Don't Repeat Yourself) 原则,建议进行重构。一个可能的方案是创建一个通用的类来包含共享的样式,然后让 .html-body__effect-background 和 .html-body__effect-background-overlay 都使用这个通用类,从而消除重复。
| const ebg = document.querySelector('.html-body__effect-background') as HTMLElement; | ||
| import { DEFAULT_BG_IN_DURATION } from '@/Core/constants'; | ||
|
|
||
| let previousImageUrl = ''; |
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.
使用模块级别的变量 previousImageUrl 来存储状态,会使 setEbg 函数变为有状态的(stateful)函数,并且不是可重入的(non-reentrant)。
虽然在当前的使用场景下(可能只有一个地方调用它),这可能不会造成问题,但如果未来有多个独立的组件需要调用 setEbg,它们会共享 previousImageUrl 这个状态,可能导致非预期的行为和竞态条件。
为了提高代码的健壮性和可维护性,建议将状态管理与函数逻辑分离。例如,可以创建一个 EbgManager 类来封装状态和逻辑,或者修改 setEbg 函数,让调用者负责维护和传递上一个 URL,使其成为一个无状态的纯函数。
介绍
让 ebg 切换背景图片时有过渡