Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{% assign t = site.data.locales[page.lang][page.lang] %}
<button id="scrollToTopButton" title="Go to top">Scroll to Top</button>
<button id="scrollToTopButton" type="button" title="Scroll to top" aria-label="Scroll to top">
<svg aria-hidden="true" viewBox="0 0 24 24" focusable="false">
<path d="M12 4L5 11h4v9h6v-9h4z"></path>
</svg>
</button>
<footer class="bg-white border-top text-center pt-5">
<div class="container-lg p-responsive mx-auto">

Expand Down
30 changes: 23 additions & 7 deletions assets/css/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@
bottom: 20px;
right: 20px;
z-index: 99;
font-size: 16px;
background-color: #333;
color: #fff;
border: none;
width: 44px;
height: 44px;
padding: 0;
align-items: center;
justify-content: center;
background-color: #fff;
color: #6a737d;
border: 1px solid #d0d7de;
cursor: pointer;
padding: 10px;
border-radius: 4px;
}
border-radius: 50%;
box-shadow: 0 2px 6px rgba(27, 31, 35, 0.12);
}

#scrollToTopButton:hover {
background-color: #f6f8fa;
border-color: #afb8c1;
}

#scrollToTopButton svg {
width: 20px;
height: 26px;
display: block;
fill: currentColor;
}
31 changes: 19 additions & 12 deletions assets/js/button.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@

window.addEventListener('scroll', function () {
var scrollToTopButton = document.getElementById('scrollToTopButton');
if (window.scrollY > 300) {
scrollToTopButton.style.display = 'block';
} else {
scrollToTopButton.style.display = 'none';
}
});

document.getElementById('scrollToTopButton').addEventListener('click', function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
var scrollToTopButton = document.getElementById('scrollToTopButton');

if (scrollToTopButton) {
var toggleScrollToTopButton = function () {
if (window.scrollY > 300) {
scrollToTopButton.style.display = 'flex';
} else {
scrollToTopButton.style.display = 'none';
}
};

window.addEventListener('scroll', toggleScrollToTopButton);

scrollToTopButton.addEventListener('click', function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
});

toggleScrollToTopButton();
}

Loading