Skip to content

Commit

Permalink
remove scroll up after scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
svbaelen committed Apr 12, 2024
1 parent 94a1e6c commit 9e19b94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
17 changes: 10 additions & 7 deletions config/html/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -833,15 +833,18 @@ input:checked + .slider:before {
transform: rotate(180deg);
}

#btn-scroll-bottom:hover svg,
#btn-scroll-top:hover svg {
stroke: var(--color-link);
}
#btn-scroll-bottom:focus svg,
#btn-scroll-top:focus svg {
stroke: #aaa;
@media only screen and (min-width: 1024px) {
#btn-scroll-bottom:hover svg,
#btn-scroll-top:hover svg {
stroke: var(--color-link);
}
#btn-scroll-bottom:focus svg,
#btn-scroll-top:focus svg {
stroke: #aaa;
}
}


/*#sidebar-right:hover #btn-scroll-bottom,*/
#scroll-buttons:hover #btn-scroll-top {
display:flex !important;
Expand Down
12 changes: 9 additions & 3 deletions src/scripts/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,24 @@ function mainScrollBtns() {
// container
const scrollBtnContainer = document.querySelector("#scroll-buttons");
scrollBtnContainer.style.display = "flex";
/* trigger on scroll */
let newTimeout = null;

// up
const btnScrollTop = document.querySelector("#btn-scroll-top");
//btnScrollTop.style.display = "flex";
btnScrollTop.addEventListener("click", (ev) => {
ev.preventDefault();
window.scrollTo(0, 0);
if (newTimeout) clearTimeout(newTimeout);
history.pushState(
"", document.title, window.location.pathname + window.location.search
);
// wait until scroll to top (very brute, should listen to event!!)
setTimeout(() => {
btnScrollTop.style.display = 'none';
}, 200);

});
// down
/*const btnScrollBottom = document.querySelector("#lbar-buttons #btn-scroll-bottom");*/
Expand All @@ -27,9 +36,6 @@ function mainScrollBtns() {
/*window.scrollTo(0, document.body.scrollHeight);*/
/*});*/

/* trigger on scroll */
let newTimeout = null;

window.addEventListener('scroll', e => {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if (scrollTop > LAST_SCROLL_TOP) {
Expand Down

0 comments on commit 9e19b94

Please sign in to comment.