@downpw Of course it’s possible to share
Here’s the CSS
#btt {
display: inline-block;
background: rgba(0, 0, 0, 0.2);
width: 50px;
height: 50px;
text-align: center;
border-radius: 4px;
position: fixed;
bottom: 50px;
right: 30px;
transition: background-color .3s, opacity .5s, visibility .5s;
opacity: 0;
visibility: hidden;
}
#btt.show {
opacity: 1;
visibility: visible;
z-index: 10000;
color: #ffffff;
}
a#btt.show:hover {
box-shadow: inset 0px 0px 0px 1px #4F707A !important;
}
a#btt i {
position: absolute;
top: 32%;
left: 35%;
}
Obviously, style to suit your own site
And here’s the JS
$(window).on('action:ajaxify.end', function (data) {
var matched = false;
var btn = $('#btt');
var bar = $('.reading-meter');
bar.removeClass('show');
$(window).scroll(function () {
if ($(window).scrollTop() > 300) {
btn.addClass('show');
bar.addClass('show');
} else {
btn.removeClass('show');
bar.removeClass('show');
}
if (window.location.href.indexOf("topic") > -1) {
if (matched == false) {
console.log("This is a topic, so hide the scroll top feature");
matched = true;
}
btn.removeClass('show');
}
});
btn.on('click', function (e) {
e.preventDefault();
$('html, body').animate({ scrollTop: 0 }, '300');
});
});
Some points
bar.addClass('show');
and bar.removeClass('show');
are only required if you are using the progress-meter
code. Essentially, the two are designed to work together with the code above, but it won’t matter that much if you aren’t using the progress-meter (however, you may land up with some errors in the console).