Skip to content

Commit

Permalink
PLANET-4811 Hide backtop when at top
Browse files Browse the repository at this point in the history
  • Loading branch information
Inwerpsel committed Sep 25, 2020
1 parent 4275f9d commit 41347e3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion assets/src/blocks/Submenu/SubmenuFrontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ export const SubmenuFrontend = ({ title, className, levels, submenu_style }) =>
if (!backTop) {
return;
}
backTop.classList.remove('d-none');
document.addEventListener('scroll', () => {
if (document.documentElement.scrollTop > 400) {
backTop.classList.remove('d-none');
} else {
backTop.classList.add('d-none');
}
});
};

// Enable back top on initial render.
Expand Down

0 comments on commit 41347e3

Please sign in to comment.