Skip to content

Commit

Permalink
feat: 优化滚动条的隐藏逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanzm committed Dec 24, 2023
1 parent df51ce5 commit 42fed45
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/scrollbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export default class ScrollBar extends View {
public autoHide = true;

// 滚动完毕后自动隐藏时间
public autoHideTime = 1500;
public autoHideTime = 2000;

public autoHideDelayTime = 1500;

private autoHideRemainingTime = 0;

Expand Down Expand Up @@ -137,7 +139,7 @@ export default class ScrollBar extends View {

if (checkNeedHideScrollBar(this.direction, dimensions)) {
this.hide();
} else {
} else if (this.isHide) {
this.show();
}

Expand All @@ -151,6 +153,8 @@ export default class ScrollBar extends View {
} else {
this.style.left = scrollLeft;
}

this.autoHideRemainingTime = this.autoHideTime + this.autoHideDelayTime;
}

calculteScrollValue(left: number, top: number) {
Expand Down Expand Up @@ -192,7 +196,8 @@ export default class ScrollBar extends View {
}

if (this.autoHide) {
this.autoHideRemainingTime = this.autoHideTime;
// this.autoHideRemainingTime = this.autoHideTime;
this.autoHideRemainingTime = this.autoHideTime + this.autoHideDelayTime;
}

this.style.opacity = 1;
Expand Down

0 comments on commit 42fed45

Please sign in to comment.