<button class="back-to-top" aria-label="Back To Top">
<i class="fas fa-chevron-up" aria-hidden="true"></i>
</button>
<button class="back-to-top" aria-label="{{label}}">
<i class="fas fa-chevron-up" aria-hidden="true"></i>
</button>
{
"label": "Back To Top"
}
$(function() {
const $backToTop = $('.back-to-top')
$backToTop.on('click touch', () => {
document.body.scrollTop = 0
document.documentElement.scrollTop = 0
})
$(window).on('load resize scroll', () => {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
$backToTop.fadeIn()
} else {
$backToTop.fadeOut()
}
})
})
.back-to-top {
$this: &;
background: #3074DC;
border: none;
border-radius: rem(4px);
box-shadow: 0 10px 20px rgba($color-black, 0.2);
color: $color-white;
cursor: pointer;
font-size: rem(18px);
outline: none;
padding: rem(15px);
position: fixed;
bottom: 100px;
right: 30px;
z-index: 999;
&:hover,
&:focus {
background: $color-primary-red;
}
}
No notes defined.