feat(floating-button): add pointer-based drag with edge snapping#51
Open
shallowaria wants to merge 1 commit into
Open
feat(floating-button): add pointer-based drag with edge snapping#51shallowaria wants to merge 1 commit into
shallowaria wants to merge 1 commit into
Conversation
- Implement drag via Pointer Events with threshold detection - Extract position math to utils/floating-button-position.ts (clamp, snap, initial) - Snap to nearest horizontal edge on release - Re-clamp position on window resize - Suppress click after drag to prevent accidental toggles - Add unit tests for position utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
更改类型
更改描述
为悬浮球添加拖拽功能,用户可以自由拖动按钮到屏幕任意位置,松手后自动吸附到最近的水平边缘。
相关 Issue
N/A
测试
utils/tests/floating-button-position.browser.ts 覆盖:
初始位置计算(右下角)
边界 clamp(超出视口时限制在安全区域内)
左半屏释放吸附到左边缘
右半屏释放吸附到右边缘
getFloatingButtonViewport 返回当前窗口尺寸
刷新时悬浮球位置是否保存
添加了单元测试
手动测试通过
测试了两种语言(如涉及 UI 更改)
截图(如适用)
(添加截图展示 UI 变化)
检查清单