Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDillon <dillonzq@outlook.com>2020-05-18 17:27:01 +0300
committerGitHub <noreply@github.com>2020-05-18 17:27:01 +0300
commit9dd5230204491e2ac61514ae22079ff0b6cd4ec9 (patch)
treeb4cd737f554e79a845ab126f81e04ac60c8c773f /src
parent8f53c999e524d6b4e5ff912c83c7be0ca9d36e62 (diff)
feat(TOC): add keepStatic param for TOC (#372)
Diffstat (limited to 'src')
-rw-r--r--src/js/theme.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/js/theme.js b/src/js/theme.js
index f32e5d6..91b4b9f 100644
--- a/src/js/theme.js
+++ b/src/js/theme.js
@@ -397,7 +397,7 @@ class Theme {
initToc() {
const $tocCore = document.getElementById('TableOfContents');
if ($tocCore === null) return;
- if (this.util.isTocStatic()) {
+ if (document.getElementById('toc-static').getAttribute('kept') || this.util.isTocStatic()) {
const $tocContentStatic = document.getElementById('toc-content-static');
if ($tocCore.parentElement !== $tocContentStatic) {
$tocCore.parentElement.removeChild($tocCore);
@@ -640,29 +640,34 @@ class Theme {
$viewComments.style.display = 'block';
}
const $fixedButtons = document.getElementById('fixed-buttons');
- const MIN_SCROLL = 20;
+ const ACCURACY = 20, MINIMUM = 100;
window.addEventListener('scroll', () => {
this.newScrollTop = this.util.getScrollTop();
const scroll = this.newScrollTop - this.oldScrollTop;
+ const isMobile = this.util.isMobile();
this.util.forEach($headers, $header => {
- if (scroll > MIN_SCROLL) {
+ if (scroll > ACCURACY) {
$header.classList.remove('fadeInDown');
this.util.animateCSS($header, ['fadeOutUp', 'faster'], true);
- } else if (scroll < - MIN_SCROLL) {
+ } else if (scroll < - ACCURACY) {
$header.classList.remove('fadeOutUp');
this.util.animateCSS($header, ['fadeInDown', 'faster'], true);
}
});
- if (this.newScrollTop > MIN_SCROLL) {
- if (scroll > MIN_SCROLL) {
+ if (this.newScrollTop > MINIMUM) {
+ if (isMobile && scroll > ACCURACY) {
$fixedButtons.classList.remove('fadeIn');
this.util.animateCSS($fixedButtons, ['fadeOut', 'faster'], true);
- } else if (scroll < - MIN_SCROLL) {
+ } else if (!isMobile || scroll < - ACCURACY) {
$fixedButtons.style.display = 'block';
$fixedButtons.classList.remove('fadeOut');
this.util.animateCSS($fixedButtons, ['fadeIn', 'faster'], true);
}
} else {
+ if (!isMobile) {
+ $fixedButtons.classList.remove('fadeIn');
+ this.util.animateCSS($fixedButtons, ['fadeOut', 'faster'], true);
+ }
$fixedButtons.style.display = 'none';
}
for (let event of this.scrollEventSet) event();