Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions frontend/src/ts/test/test-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ const resultWordsHistoryEl = qsr(".pageTest #resultWordsHistory");

export let activeWordTop = 0;
export let activeWordHeight = 0;
export let lineTransition = false;
export let currentTestLine = 0;
let wordTopBeforeLineJump = 0;
let lineTransition = false;
let currentTestLine = 0;
export let resultCalculating = false;

export function setResultCalculating(val: boolean): void {
Expand Down Expand Up @@ -902,7 +903,14 @@ export async function updateWordLetters({
if (!Config.showAllLines) {
const wordTopAfterUpdate = wordAtIndex.getOffsetTop();
if (wordTopAfterUpdate > activeWordTop) {
await lineJump(activeWordTop, true);
let jump = false;
if (!lineTransition) {
wordTopBeforeLineJump = wordTopAfterUpdate;
jump = true;
} else if (wordTopAfterUpdate > wordTopBeforeLineJump) {
jump = true;
}
if (jump) await lineJump(activeWordTop);
}
}
}
Expand Down Expand Up @@ -1163,19 +1171,13 @@ function removeTestElements(lastElementIndexToRemove: number): void {

let currentLinesJumping = 0;

export async function lineJump(
currentTop: number,
force = false,
): Promise<void> {
async function lineJump(currentTop: number, force = false): Promise<void> {
//last word of the line
if (currentTestLine > 0 || force) {
const hideBound = currentTop;

const activeWordEl = getActiveWordElement();
if (!activeWordEl) {
// resolve();
return;
}
if (!activeWordEl) return;

// index of the active word in all #words.children
// (which contains .word/.newline/.beforeNewline/.afterNewline elements)
Expand Down
Loading