calling line jump on resize event

triggering resize event on font size change to trigger this event handler
closes #3937
This commit is contained in:
Miodec 2023-01-27 15:24:45 +01:00
parent 6647a81ad1
commit 2abd0e69fe
2 changed files with 14 additions and 6 deletions

View file

@ -1611,6 +1611,9 @@ export function setFontSize(fontSize: number, nosave?: boolean): boolean {
saveToLocalStorage("fontSize", nosave);
ConfigEvent.dispatch("fontSize", config.fontSize);
// trigger a resize event to update the layout - handled in ui.ts:108
$(window).trigger("resize");
return true;
}

View file

@ -84,12 +84,17 @@ window.addEventListener("beforeunload", (event) => {
const debouncedEvent = debounce(250, async () => {
Caret.updatePosition();
if (
Config.tapeMode !== "off" &&
getActivePage() === "test" &&
!TestUI.resultVisible
) {
TestUI.scrollTape();
if (getActivePage() === "test" && !TestUI.resultVisible) {
if (Config.tapeMode !== "off") {
TestUI.scrollTape();
} else {
const currentTop: number = Math.floor(
document.querySelectorAll<HTMLElement>("#words .word")[
TestUI.currentWordElementIndex - 1
].offsetTop
);
TestUI.lineJump(currentTop);
}
}
setTimeout(() => {
Caret.show();