!49 修复ScreenLock收到消息通知后过于频繁刷新UI组件的问题

Merge pull request !49 from yangpeng85/master
This commit is contained in:
openharmony_ci 2022-07-05 06:15:50 +00:00 committed by Gitee
commit 81eb43c2c1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 16 additions and 4 deletions

View File

@ -82,8 +82,14 @@ export default struct GroupItem {
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.On)
.onScroll(() => {
this.mIconAlpha += 0.1;
this.mIconAlpha = this.mScroller.currentOffset().xOffset * 1.0 / getIconListSize();
let accuracy = 0.1
let newOpacity = this.mScroller.currentOffset().xOffset * 1.0 / getIconListSize()
let diffs = Math.abs(this.mIconAlpha - newOpacity)
if (diffs >= accuracy) {
let finalAlpha = newOpacity < accuracy ? 0 : newOpacity
finalAlpha = finalAlpha > (1 - accuracy) ? 1 : finalAlpha
this.mIconAlpha = finalAlpha
}
})
.onScrollEnd(() => {
this.mEdgeEnd = (this.mEdgeEnd &&

View File

@ -47,8 +47,14 @@ export default struct NotificationItem {
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.On)
.onScroll(() => {
this.mIconAlpha += 0.1;
this.mIconAlpha = this.mScroller.currentOffset().xOffset * 1.0 / getIconListSize();
let accuracy = 0.1
let newOpacity = this.mScroller.currentOffset().xOffset * 1.0 / getIconListSize()
let diffs = Math.abs(this.mIconAlpha - newOpacity)
if (diffs >= accuracy) {
let finalAlpha = newOpacity < accuracy ? 0 : newOpacity
finalAlpha = finalAlpha > (1 - accuracy) ? 1 : finalAlpha
this.mIconAlpha = finalAlpha
}
})
.onScrollEnd(() => {
this.mEdgeEnd = (this.mEdgeEnd &&