Skip to content

Commit f84f850

Browse files
committed
fix: scroll to top button remaining visible on the test page
1 parent 0833e1e commit f84f850

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

frontend/src/ts/elements/scroll-to-top.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import { prefersReducedMotion } from "../utils/misc";
33

44
let visible = false;
55

6+
export function hide(): void {
7+
$(".scrollToTopButton").addClass("invisible");
8+
visible = false;
9+
}
10+
11+
function show(): void {
12+
$(".scrollToTopButton").removeClass("invisible");
13+
visible = true;
14+
}
15+
616
$(document).on("click", ".scrollToTopButton", () => {
717
$(".scrollToTopButton").addClass("invisible");
818
window.scrollTo({
@@ -17,10 +27,8 @@ $(window).on("scroll", () => {
1727

1828
const scroll = window.scrollY;
1929
if (!visible && scroll > 100) {
20-
$(".scrollToTopButton").removeClass("invisible");
21-
visible = true;
30+
show();
2231
} else if (visible && scroll < 100) {
23-
$(".scrollToTopButton").addClass("invisible");
24-
visible = false;
32+
hide();
2533
}
2634
});

frontend/src/ts/pages/test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { updateFooterAndVerticalAds } from "../controllers/ad-controller";
77
import * as ModesNotice from "../elements/modes-notice";
88
import * as Keymap from "../elements/keymap";
99
import * as TestConfig from "../test/test-config";
10+
import * as ScrollToTop from "../elements/scroll-to-top";
1011

1112
export const page = new Page({
1213
name: "test",
@@ -32,5 +33,6 @@ export const page = new Page({
3233
void TestConfig.instantUpdate();
3334
void Funbox.activate();
3435
void Keymap.refresh();
36+
ScrollToTop.hide();
3537
},
3638
});

0 commit comments

Comments
 (0)