The New Scroll
A button to return to the top of the page allows the user to quickly return to the top of the page without making too much effort
352 Words … ⏲ Reading Time: 1 Minute, 36 Seconds
2023-08-06 10:37 +0000
This article explains how to use Scroll Up
A button to return to the top of the page allows the user to quickly return to the top of the page without making too much effort. This can be very useful when the page has a lot of content or which happens, for example, on one page websites, when infinite scrolling is used, or on mobile devices where different screen sizes can cause the content to scroll extend.
Step 1
Set scrollToTop
to true in hugo.toml
scrollToTop = true
Step 2
Enable scrolltotop
to true
in article front matter.
scrolltotop : true
Some pages/articles do not require scroll up button (if there is less content)
Anti-JS crowd
The button will work as intended if JS is disabled, but it will not hide/show on scroll position. So, if you have decided to disable JS on client, you will be struck with an floating icon.
Icon
Icon is located in layouts/partials/svg.html
under scrollup.
Icon svg code is as follows:
|
|
HTML
This is implemented as a partial located in layouts/partials/scroll-to-top.html
.
Partial is injected in layouts/_default/baseof.html
|
|
CSS
Located in assets/scss/_scrolltotop.scss
.
|
|
JavaScript
Located in assets/js/scrollwatcher.js
|
|