fix: prevent ListView overscroll in notification panel#1516
fix: prevent ListView overscroll in notification panel#1516qxp930712 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
Added overscroll protection to the notification center ListView to prevent unwanted bounce-back behavior when scrolling beyond content boundaries. The fix includes three event handlers that monitor height, content height, and content position changes to ensure the scroll position stays within valid bounds. Implemented bounds checking in onHeightChanged, onContentHeightChanged, and onContentYChanged handlers to clamp the contentY position when it exceeds the content boundaries. This prevents the ListView from showing empty space when scrolled beyond the actual content area, which was causing visual glitches and inconsistent scrolling behavior. Influence: 1. Test scrolling to the top and bottom of notification list 2. Verify no empty space appears when reaching content boundaries 3. Check that normal scrolling behavior remains smooth 4. Test with various numbers of notifications (empty, few, many) 5. Verify scroll position is maintained during content updates PMS: BUG-284867
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: qxp930712 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto review这段代码主要针对 QML 中 以下是对这段代码的详细审查意见: 1. 语法与逻辑审查
2. 代码质量与规范
3. 改进意见与建议建议 1:优先使用原生属性
|
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds overscroll protection to the notification center ListView by clamping contentY within valid bounds in response to height, content height, and scroll position changes, preventing bounce-back and empty-space glitches at the list edges. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The clamping logic for
contentHeight > height && contentY > contentHeight - heightis duplicated inonHeightChangedandonContentHeightChanged; consider extracting this into a small helper function to keep the behavior consistent and easier to maintain. - The magic offsets
contentY < -1andcontentY > contentHeight - height + 1inonContentYChangedcould use either named constants or an inline comment explaining why a 1‑pixel tolerance is required here to avoid future confusion or accidental changes. - Since ListView/Flickable already expose
boundsBehaviorand related properties, it might be worth checking whether you can achieve the same non-overscroll behavior by configuring those instead of manually reassigningcontentYin three handlers, which can be harder to reason about over time.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The clamping logic for `contentHeight > height && contentY > contentHeight - height` is duplicated in `onHeightChanged` and `onContentHeightChanged`; consider extracting this into a small helper function to keep the behavior consistent and easier to maintain.
- The magic offsets `contentY < -1` and `contentY > contentHeight - height + 1` in `onContentYChanged` could use either named constants or an inline comment explaining why a 1‑pixel tolerance is required here to avoid future confusion or accidental changes.
- Since ListView/Flickable already expose `boundsBehavior` and related properties, it might be worth checking whether you can achieve the same non-overscroll behavior by configuring those instead of manually reassigning `contentY` in three handlers, which can be harder to reason about over time.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| // ListView滚轮回弹行为是默认行为,需要手动修正 | ||
| onHeightChanged: { | ||
| if (contentHeight > height && contentY > contentHeight - height) { |
Added overscroll protection to the notification center ListView to prevent unwanted bounce-back behavior when scrolling beyond content boundaries. The fix includes three event handlers that monitor height, content height, and content position changes to ensure the scroll position stays within valid bounds.
Implemented bounds checking in onHeightChanged, onContentHeightChanged, and onContentYChanged handlers to clamp the contentY position when it exceeds the content boundaries. This prevents the ListView from showing empty space when scrolled beyond the actual content area, which was causing visual glitches and inconsistent scrolling behavior.
Influence:
PMS: BUG-284867
Summary by Sourcery
Bug Fixes: