💄 Add new tool buttons in page side.

This commit is contained in:
凡梦星尘
2022-09-25 21:40:36 +08:00
parent 523c12f0ec
commit 4037ea0d68
16 changed files with 1191 additions and 46 deletions

View File

@@ -23,6 +23,15 @@ HTMLElement.prototype.wrap = function(wrapper) {
NexT.utils = {
domAddClass: function(selector, cls) {
const doms = document.querySelectorAll(selector);
if (doms) {
doms.forEach(dom => {
dom.classList.add(cls);
});
}
},
calSiteInfo: function() {
const runtimeCount = document.getElementById('runTimes');
if (runtimeCount) {
@@ -276,8 +285,10 @@ NexT.utils = {
const contentHeight = document.body.scrollHeight - window.innerHeight;
const scrollPercent = contentHeight > 0 ? Math.min(100 * window.scrollY / contentHeight, 100) : 0;
if (backToTop) {
backToTop.classList.toggle('back-to-top-on', Math.round(scrollPercent) >= 5);
backToTop.querySelector('span').innerText = Math.round(scrollPercent) + '%';
const scrollPercentRound = Math.round(scrollPercent)
const isShow = scrollPercentRound >= 5;
backToTop.classList.toggle('back-to-top-on', isShow);
backToTop.querySelector('span').innerText = scrollPercentRound + '%';
}
if (readingProgressBar) {
readingProgressBar.style.setProperty('--progress', scrollPercent.toFixed(2) + '%');