fix: scroll to top button remaining visible on the test page

This commit is contained in:
Miodec 2025-03-15 11:34:41 +01:00
parent 0833e1efc7
commit f84f8508ca
2 changed files with 14 additions and 4 deletions

View file

@ -3,6 +3,16 @@ import { prefersReducedMotion } from "../utils/misc";
let visible = false;
export function hide(): void {
$(".scrollToTopButton").addClass("invisible");
visible = false;
}
function show(): void {
$(".scrollToTopButton").removeClass("invisible");
visible = true;
}
$(document).on("click", ".scrollToTopButton", () => {
$(".scrollToTopButton").addClass("invisible");
window.scrollTo({
@ -17,10 +27,8 @@ $(window).on("scroll", () => {
const scroll = window.scrollY;
if (!visible && scroll > 100) {
$(".scrollToTopButton").removeClass("invisible");
visible = true;
show();
} else if (visible && scroll < 100) {
$(".scrollToTopButton").addClass("invisible");
visible = false;
hide();
}
});

View file

@ -7,6 +7,7 @@ import { updateFooterAndVerticalAds } from "../controllers/ad-controller";
import * as ModesNotice from "../elements/modes-notice";
import * as Keymap from "../elements/keymap";
import * as TestConfig from "../test/test-config";
import * as ScrollToTop from "../elements/scroll-to-top";
export const page = new Page({
name: "test",
@ -32,5 +33,6 @@ export const page = new Page({
void TestConfig.instantUpdate();
void Funbox.activate();
void Keymap.refresh();
ScrollToTop.hide();
},
});