Skip to content

Commit 67584e3

Browse files
committed
animate #words.margin when turning tape mode off
1 parent e4bab6f commit 67584e3

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

frontend/src/ts/test/test-ui.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,30 @@ function updateWordsMargin(): void {
590590
if (Config.tapeMode !== "off") {
591591
void scrollTape();
592592
} else {
593-
setTimeout(() => {
594-
$("#words").css("margin-left", "unset");
595-
$("#words .afterNewline").css("margin-left", "unset");
596-
}, 0);
593+
const wordsEl = document.getElementById("words") as HTMLElement;
594+
const afterNewlineEls =
595+
wordsEl.querySelectorAll<HTMLElement>(".afterNewline");
596+
if (Config.smoothLineScroll) {
597+
const jqWords = $(wordsEl);
598+
jqWords.stop("leftMargin", true, false).animate(
599+
{
600+
marginLeft: 0,
601+
},
602+
{
603+
duration: SlowTimer.get() ? 0 : 125,
604+
queue: "leftMargin",
605+
}
606+
);
607+
jqWords.dequeue("leftMargin");
608+
$(afterNewlineEls)
609+
.stop(true, false)
610+
.animate({ marginLeft: 0 }, SlowTimer.get() ? 0 : 125);
611+
} else {
612+
wordsEl.style.marginLeft = `0`;
613+
for (const afterNewline of afterNewlineEls) {
614+
afterNewline.style.marginLeft = `0`;
615+
}
616+
}
597617
}
598618
}
599619

0 commit comments

Comments
 (0)