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-03-16 21:03:36 +0300
committerGitHub <noreply@github.com>2020-03-16 21:03:36 +0300
commit80db7833963a0b43bcca86cecfb7eb83a6e1aa50 (patch)
tree38eb76abc31f23479a6ddbf5ab694f6e135fb549 /src
parent0ca8a4c85ba198b0614f360fe38145371b78fd80 (diff)
feat(fixed-btns): add title for fixed buttons (#176)
Diffstat (limited to 'src')
-rw-r--r--src/js/theme.js34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/js/theme.js b/src/js/theme.js
index 471979c..06abc46 100644
--- a/src/js/theme.js
+++ b/src/js/theme.js
@@ -250,15 +250,11 @@
});
const comments = document.getElementsByClassName('comment') || [];
if (comments.length) {
- const container = document.getElementById('fixed-btn-container');
- const button = document.createElement('a');
+ const button = document.getElementById('comment-button');
button.href = `#${comments[0].id}`;
- button.id = 'comment-button';
- button.className = 'fixed-button animated faster';
- button.innerHTML = '<i class="fas fa-comment fa-fw"></i>';
- container.appendChild(button);
+ button.style.display = 'block';
}
- const buttons = document.getElementsByClassName('fixed-button');
+ const fixedButtons = document.getElementById('fixed-buttons');
const MIN_SCROLL = 10;
window.addEventListener('scroll', () => {
this.newScrollTop = this.util.getScrollTop();
@@ -272,20 +268,18 @@
header.classList.add('fadeInDown');
}
});
- this.util.forEach(buttons, (button) => {
- if (this.newScrollTop > 20) {
- if (scroll > MIN_SCROLL) {
- button.classList.remove('fadeIn');
- button.classList.add('fadeOut');
- } else if (scroll < - MIN_SCROLL) {
- button.style.display = 'block';
- button.classList.remove('fadeOut');
- button.classList.add('fadeIn');
- }
- } else {
- button.style.display = 'none';
+ if (this.newScrollTop > 20) {
+ if (scroll > MIN_SCROLL) {
+ fixedButtons.classList.remove('fadeIn');
+ fixedButtons.classList.add('fadeOut');
+ } else if (scroll < - MIN_SCROLL) {
+ fixedButtons.style.display = 'block';
+ fixedButtons.classList.remove('fadeOut');
+ fixedButtons.classList.add('fadeIn');
}
- });
+ } else {
+ fixedButtons.style.display = 'none';
+ }
if (!this._scrollTimeout) {
this._scrollTimeout = window.setTimeout(() => {
this._scrollTimeout = null;