mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-14 10:56:16 +01:00
feat(fixed-btns): add title for fixed buttons (#176)
This commit is contained in:
parent
0ca8a4c85b
commit
80db783396
9 changed files with 53 additions and 29 deletions
|
@ -1,11 +1,11 @@
|
||||||
|
#fixed-buttons {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.fixed-button {
|
.fixed-button {
|
||||||
display: none;
|
display: none;
|
||||||
overflow: hidden;
|
|
||||||
width: auto;
|
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: auto;
|
|
||||||
left: auto;
|
|
||||||
right: 1.5rem;
|
right: 1.5rem;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
line-height: 1.3rem;
|
line-height: 1.3rem;
|
||||||
|
@ -36,6 +36,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#top-button {
|
#top-button {
|
||||||
|
display: block;
|
||||||
bottom: 1.5rem;
|
bottom: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
assets/js/theme.min.js
vendored
2
assets/js/theme.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,14 @@
|
||||||
# Translations for English
|
# Translations for English
|
||||||
# https://gohugo.io/content-management/multilingual/#translation-of-strings
|
# https://gohugo.io/content-management/multilingual/#translation-of-strings
|
||||||
|
|
||||||
|
# === baseof ==
|
||||||
|
[backToTop]
|
||||||
|
other = "Back to Top"
|
||||||
|
|
||||||
|
[viewComments]
|
||||||
|
other = "View Comments"
|
||||||
|
# === baseof ==
|
||||||
|
|
||||||
# === Post ===
|
# === Post ===
|
||||||
[posts]
|
[posts]
|
||||||
other = "Posts"
|
other = "Posts"
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
# Translations for French
|
# Translations for French
|
||||||
# https://gohugo.io/content-management/multilingual/#translation-of-strings
|
# https://gohugo.io/content-management/multilingual/#translation-of-strings
|
||||||
|
|
||||||
|
# === baseof ==
|
||||||
|
[backToTop]
|
||||||
|
other = "Retour en Haut"
|
||||||
|
|
||||||
|
[viewComments]
|
||||||
|
other = "Afficher les Commentaires"
|
||||||
|
# === baseof ==
|
||||||
|
|
||||||
# === Post ===
|
# === Post ===
|
||||||
[posts]
|
[posts]
|
||||||
other = "Posts"
|
other = "Posts"
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
# Translations for Simplified Chinese
|
# Translations for Simplified Chinese
|
||||||
# https://gohugo.io/content-management/multilingual/#translation-of-strings
|
# https://gohugo.io/content-management/multilingual/#translation-of-strings
|
||||||
|
|
||||||
|
# === baseof ==
|
||||||
|
[backToTop]
|
||||||
|
other = "回到顶部"
|
||||||
|
|
||||||
|
[viewComments]
|
||||||
|
other = "查看评论"
|
||||||
|
# === baseof ==
|
||||||
|
|
||||||
# === Post ===
|
# === Post ===
|
||||||
[posts]
|
[posts]
|
||||||
other = "文章"
|
other = "文章"
|
||||||
|
|
|
@ -58,11 +58,16 @@
|
||||||
{{- partial "footer.html" . -}}
|
{{- partial "footer.html" . -}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="fixed-btn-container">
|
<div id="fixed-buttons" class="animated faster">
|
||||||
{{- /* top button */ -}}
|
{{- /* top button */ -}}
|
||||||
<a href="#" id="top-button" class="fixed-button animated faster">
|
<a href="#" id="top-button" class="fixed-button" title="{{ T `backToTop` }}">
|
||||||
<i class="fas fa-arrow-up fa-fw"></i>
|
<i class="fas fa-arrow-up fa-fw"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
{{- /* comment button */ -}}
|
||||||
|
<a href="#" id="comment-button" class="fixed-button" title="{{ T `viewComments` }}">
|
||||||
|
<i class="fas fa-comment fa-fw"></i>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{- /* Load JavaScript scripts and CSS */ -}}
|
{{- /* Load JavaScript scripts and CSS */ -}}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -250,15 +250,11 @@
|
||||||
});
|
});
|
||||||
const comments = document.getElementsByClassName('comment') || [];
|
const comments = document.getElementsByClassName('comment') || [];
|
||||||
if (comments.length) {
|
if (comments.length) {
|
||||||
const container = document.getElementById('fixed-btn-container');
|
const button = document.getElementById('comment-button');
|
||||||
const button = document.createElement('a');
|
|
||||||
button.href = `#${comments[0].id}`;
|
button.href = `#${comments[0].id}`;
|
||||||
button.id = 'comment-button';
|
button.style.display = 'block';
|
||||||
button.className = 'fixed-button animated faster';
|
|
||||||
button.innerHTML = '<i class="fas fa-comment fa-fw"></i>';
|
|
||||||
container.appendChild(button);
|
|
||||||
}
|
}
|
||||||
const buttons = document.getElementsByClassName('fixed-button');
|
const fixedButtons = document.getElementById('fixed-buttons');
|
||||||
const MIN_SCROLL = 10;
|
const MIN_SCROLL = 10;
|
||||||
window.addEventListener('scroll', () => {
|
window.addEventListener('scroll', () => {
|
||||||
this.newScrollTop = this.util.getScrollTop();
|
this.newScrollTop = this.util.getScrollTop();
|
||||||
|
@ -272,20 +268,18 @@
|
||||||
header.classList.add('fadeInDown');
|
header.classList.add('fadeInDown');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.util.forEach(buttons, (button) => {
|
if (this.newScrollTop > 20) {
|
||||||
if (this.newScrollTop > 20) {
|
if (scroll > MIN_SCROLL) {
|
||||||
if (scroll > MIN_SCROLL) {
|
fixedButtons.classList.remove('fadeIn');
|
||||||
button.classList.remove('fadeIn');
|
fixedButtons.classList.add('fadeOut');
|
||||||
button.classList.add('fadeOut');
|
} else if (scroll < - MIN_SCROLL) {
|
||||||
} else if (scroll < - MIN_SCROLL) {
|
fixedButtons.style.display = 'block';
|
||||||
button.style.display = 'block';
|
fixedButtons.classList.remove('fadeOut');
|
||||||
button.classList.remove('fadeOut');
|
fixedButtons.classList.add('fadeIn');
|
||||||
button.classList.add('fadeIn');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
button.style.display = 'none';
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
fixedButtons.style.display = 'none';
|
||||||
|
}
|
||||||
if (!this._scrollTimeout) {
|
if (!this._scrollTimeout) {
|
||||||
this._scrollTimeout = window.setTimeout(() => {
|
this._scrollTimeout = window.setTimeout(() => {
|
||||||
this._scrollTimeout = null;
|
this._scrollTimeout = null;
|
||||||
|
|
Loading…
Reference in a new issue