only scrolling tape if on test screen

This commit is contained in:
Miodec 2022-04-28 15:58:33 +02:00
parent 15f97c339e
commit 7446649780

View file

@ -6,6 +6,7 @@ import * as TestActive from "./states/test-active";
import * as ConfigEvent from "./observables/config-event";
import { debounce, throttle } from "throttle-debounce";
import * as TestUI from "./test/test-ui";
import { get as getActivePage } from "./states/active-page";
export function updateKeytips(): void {
if (Config.swapEscAndTab) {
@ -77,9 +78,13 @@ window.addEventListener("beforeunload", (event) => {
}
});
const debouncedCaretUpdate = debounce(250, async () => {
const debouncedEvent = debounce(250, async () => {
Caret.updatePosition();
if (Config.tapeMode !== "off") {
if (
Config.tapeMode !== "off" &&
getActivePage() === "test" &&
!TestUI.resultVisible
) {
TestUI.scrollTape();
}
setTimeout(() => {
@ -87,13 +92,13 @@ const debouncedCaretUpdate = debounce(250, async () => {
}, 250);
});
const throttledCaretHide = throttle(250, () => {
const throttledEvent = throttle(250, () => {
Caret.hide();
});
$(window).on("resize", () => {
throttledCaretHide();
debouncedCaretUpdate();
throttledEvent();
debouncedEvent();
});
ConfigEvent.subscribe((eventKey) => {