One feature is a colorful RGB scroller positioned next to the standard scrollbar, indicating the progress of page scroll. The second feature is a classic "scroll to top" button.
FIRST FEATURE
HTML
<button onclick="topFunction()" id="myBtn" title="SCROLL ME UP!">▲▲▲</button>
JavaScript
let mybutton = document.getElementById("myBtn");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 38 || document.documentElement.scrollTop > 512) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
SECOND FEATURE
HTML
<div id="progressbar"></div>
<div id="scrollpath"></div>
JavaScript
let progress = document.getElementById('progressbar');
let totalHeight = document.body.scrollHeight - window.innerHeight;
window.onscroll = function () {
let progressHeight = (window.pageYOffset / totalHeight) * 100;
progress.style.height = progressHeight + "%";
}
CSS
::-webkit-scrollbar
{
width: 0;
}
#scrollPath
{
position: fixed;
top: 0;
right: 0;
width: 10px;
height: 100%;
background: rgba(255,255,255,0.05);
}
#progressbar
{
position: fixed;
top: 0;
right: 0;
width: 10px;
background: linear-gradient(to top, #008aff,#00ffe7);
animation: animate 5s linear infinite;
}
@keyframes animate
{
0%,100%
{
filter: hue-rotate(0deg);
}
50%
{
filter: hue-rotate(360deg);
}
}
#progressbar:before
{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to top, #008aff,#00ffe7);
filter: blur(10px);
}
#progressbar:before
{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to top, #008aff,#00ffe7);
filter: blur(30px);
}
::placeholder {
color: white;
}
Both features work fine independently, but seem to interfere with each other when used simultaneously. Any insights on how to resolve this issue?
I expect both features to work seamlessly together.