Ah right.
You can try this script:
<script>
var backToTop = document.querySelector("a.generate-back-to-top");
// Initial state
var scrollPos = 0;
// adding scroll event
window.addEventListener('scroll', function(){
// detects new state and compares it with the new one
if ((document.body.getBoundingClientRect()).top > scrollPos) {
backToTop.style.display = "none";
console.log('swipe down');
} else{
backToTop.style.display = "block";
console.log('swipe up');
}
// saves the new position for iteration.
scrollPos = (document.body.getBoundingClientRect()).top;
});
</script>
Add this on a Hook Element. Set the hook to wp_footer
and set the Display rule location to “Entire Site”.