@DownPW Here you go. Remove any other references you have in custom JS that relate to the previous progress bar, and replace with this
// Scroll to top function
$(window).on('action:ajaxify.end', function(data) {
var matched = false;
$(document).ready(function() {
var pageUp = $('#pageUp');
var bar = $('.reading-meter');
var perWidth = $('.reading-meter').width();
// Main progressbar function
function pageScroller() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("progress-bar").style.width = parseFloat(scrolled).toFixed(0) + "%";
$('#percentage').val(parseFloat(scrolled).toFixed(0) + "%");
// Prevent the mouse scroll wheel from scrolling down after the pageUp button is clicked
if ($('#pageUp').is(':focus')) {
event.preventDefault();
}
}
// Bind the pageScroller function to the window's scroll event
$(window).scroll(function() {
pageScroller();
});
// Check the URL and composer visibility separately from the scroll event
$(window).scroll(function() {
var thisURL = window.location.href;
var checkURL = ["topic", "notifications", "user"];
var isFound = false;
for (var i = 0, len = checkURL.length; i < len; i++) {
if (thisURL.indexOf(checkURL[i]) > -1) {
isFound = true;
break;
}
}
if (isFound) {
bar.removeClass('show');
pageUp.removeClass('show');
} else {
// Exception here is that we don't want the scroll bar to show when the composer is active
if ($(window).scrollTop() > 0 && (!$('[component="composer"]').is(":visible"))) {
bar.addClass('show');
pageUp.addClass('show');
} else {
bar.removeClass('show');
pageUp.removeClass('show');
}
}
});
// Scroll to top when #pageUp is clicked
$(document).on("click", "#pageUp", function(e) {
const firstTopic = $('[component="category/topic"][data-index="0"]');
if (firstTopic.length) {
$("html, body").animate({
scrollTop: 0
}, '300');
} else {
ajaxify.refresh();
}
});
});
});
Now in the custom header, remove the previous code that probably looks something like this
<div id="readingposition" class="reading-meter" style="bottom: 0px;">
<div class="pageUp" id="pageUp"><i class="fa fa-angle-double-left pointer" aria-hidden="true"></i></div>
<div class="pageDown" id="pageDown"><i class="fa fa-angle-double-right pointer" aria-hidden="true"></i></div>
<div class="reading-meter-background rounded-1 border border-gray-300 ready">
<div class="reading-meter-progress-bar rounded-1" id="progress-bar">
<input disabled="disabled" type="text" id="percentage" name="percentage">
</div>
</div>
</div>
And replace with this
<a id="pageUp" class=""><i class="fas fa-chevron-up"></i></a>
<div id="readingposition" class="reading-meter" style="bottom: 0px;">
<div class="reading-meter-background rounded-1 border border-gray-300 ready">
<div class="reading-meter-progress-bar rounded-1" id="progress-bar">
</div>
</div>
</div>
Now use the CSS provided below (note, that you may have previous CSS that already exists if you used the older version of the progress bar - you should remove that)
#pageUp {
display: inline-block;
background: var(--bs-body-component-active);
width: 50px;
height: 50px;
text-align: center;
border-radius: 0.375rem;
position: fixed;
bottom: 70px;
right: 80px;
transition: background-color .3s, opacity .5s, visibility .5s;
opacity: 0;
visibility: hidden;
}
#pageUp.show {
opacity: 1;
visibility: visible;
z-index: 10000;
color: var(--bs-body-navbar-color) !important;
}
a#pageUp.show:hover {
background: var(--bs-dropdown-link-hover-bg);
border: 1px solid var(--bs-border-color);
}
a#pageUp i {
position: absolute;
top: 32%;
left: 35%;
}
.reading-meter {
position: fixed;
width: 100%;
top: 0;
left: 0;
right: 0;
height: 2px !important;
}
.reading-meter {
visibility: hidden;
}
.reading-meter.show {
visibility: visible;
}
div#readingposition {
background-color: var(--bs-body-navbar) !important;
color: var(--bs-body-color) !important;
height: 2px;
z-index: 1000;
}
.reading-meter-progress {
border: 1px solid var(--bs-border-color);
width: 100%;
}
.reading-meter-background {
background: var(--bs-body-bg);
}
.reading-meter-progress-bar {
background: var(--bs-progress-bg-bar);
height: 2px;
}
input#percentage {
display: none;
}
@media (max-width: 767px) {
#pageUp {
bottom: 60px;
right: 30px;
}
}
That should do it.