fix: fixed where scrolling percent 0 does not hide
This commit is contained in:
parent
2e1d34ba55
commit
b7a0645751
|
@ -95,20 +95,12 @@ $tools-item-border-radius = 1px;
|
|||
display: flex;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
.arrow-up, .percent {
|
||||
transition-t("display", "5", "0.2", "linear");
|
||||
}
|
||||
|
||||
|
||||
.arrow-up {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
.percent {
|
||||
display: flex;
|
||||
font-size: 1rem;
|
||||
|
|
|
@ -26,23 +26,23 @@ KEEP.initUtils = () => {
|
|||
const scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
||||
const scrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
|
||||
const clientHeight = window.innerHeight || document.documentElement.clientHeight;
|
||||
const percent = Math.round(scrollTop / (scrollHeight - clientHeight) * 100).toFixed(0);
|
||||
|
||||
const percent = Math.round(scrollTop / (scrollHeight - clientHeight) * 100);
|
||||
|
||||
if (this.isHasScrollProgressBar) {
|
||||
const ProgressPercent = (scrollTop / (scrollHeight - clientHeight) * 100).toFixed(3);
|
||||
this.scrollProgressBar_dom.style.visibility = percent === '0' ? 'hidden' : 'visible';
|
||||
this.scrollProgressBar_dom.style.visibility = percent === 0 ? 'hidden' : 'visible';
|
||||
this.scrollProgressBar_dom.style.width = `${ProgressPercent}%`;
|
||||
}
|
||||
|
||||
if (this.isHasScrollPercent) {
|
||||
const percent_dom = this.back2TopButton_dom.querySelector('.percent');
|
||||
if (percent === '0') {
|
||||
this.back2TopButton_dom.classList.remove('show');
|
||||
} if (percent !== percent || !isFinite(percent)) {
|
||||
if (percent === 0 || percent === undefined) {
|
||||
this.back2TopButton_dom.classList.remove('show');
|
||||
|
||||
} else {
|
||||
this.back2TopButton_dom.classList.add('show');
|
||||
percent_dom.innerHTML = percent;
|
||||
percent_dom.innerHTML = percent.toFixed(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue