-
Notifications
You must be signed in to change notification settings - Fork 273
feat:划词翻译跟随元素滚动 #151
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?
feat:划词翻译跟随元素滚动 #151
Conversation
Reviewer's GuideThis PR replaces manual DOM measurement and style bindings for the selection indicator and tooltip with floating-ui’s computePosition and autoUpdate, enabling automatic placement and scroll-following. It refactors the template to wrap the indicator and tooltip in a positioned container, swaps out computed style logic for a watchEffect-driven update, and overhauls the CSS to use data-placement rules. Sequence diagram for selection and tooltip positioning with floating-uisequenceDiagram
actor User
participant SelectionTranslator
participant floating-ui
User->>SelectionTranslator: Selects text
SelectionTranslator->>floating-ui: computePosition(range, container)
floating-ui-->>SelectionTranslator: Returns x, y, placement
SelectionTranslator->>SelectionTranslator: Updates container style and data-placement
Note over SelectionTranslator: Tooltip and indicator follow scroll automatically
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `components/SelectionTranslator.vue:679` </location>
<code_context>
+ top: 0;
+ left: 0;
+ z-index: 9998;
+ width: 350px;
+}
+
</code_context>
<issue_to_address>
Hardcoding the wrapper width to 350px may reduce flexibility.
A fixed width may not display well on all devices or with varying content lengths. Making the width responsive or configurable would improve adaptability.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
width: 350px;
}
=======
width: var(--translator-width, 100%);
max-width: 350px;
}
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| width: 350px; | ||
| } |
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.
suggestion: Hardcoding the wrapper width to 350px may reduce flexibility.
A fixed width may not display well on all devices or with varying content lengths. Making the width responsive or configurable would improve adaptability.
| width: 350px; | |
| } | |
| width: var(--translator-width, 100%); | |
| max-width: 350px; | |
| } |
通过引入 floating-ui 实现划词翻译自动定位,自动跟随滚动
fix #143 #145