@@ -223,7 +223,7 @@ export function setResultCalculating(val: boolean): void {
223
223
224
224
export function reset ( ) : void {
225
225
currentTestLine = 0 ;
226
- TestState . setActiveWordElementOffset ( 0 ) ;
226
+ TestState . setRemovedUIWordCount ( 0 ) ;
227
227
}
228
228
229
229
export function focusWords ( ) : void {
@@ -248,7 +248,7 @@ export function updateActiveElement(
248
248
active . classList . remove ( "active" ) ;
249
249
}
250
250
const newActiveWord = document . querySelectorAll ( "#words .word" ) [
251
- TestState . activeWordIndex - TestState . activeWordElementOffset
251
+ TestState . activeWordIndex - TestState . removedUIWordCount
252
252
] as HTMLElement | undefined ;
253
253
254
254
if ( newActiveWord === undefined ) {
@@ -438,7 +438,7 @@ export async function updateWordsInputPosition(initial = false): Promise<void> {
438
438
439
439
const activeWord =
440
440
document . querySelectorAll < HTMLElement > ( "#words .word" ) [
441
- TestState . activeWordIndex - TestState . activeWordElementOffset
441
+ TestState . activeWordIndex - TestState . removedUIWordCount
442
442
] ;
443
443
444
444
if ( ! activeWord ) {
@@ -490,7 +490,7 @@ export async function centerActiveLine(): Promise<void> {
490
490
491
491
const wordElements = document . querySelectorAll < HTMLElement > ( "#words .word" ) ;
492
492
const activeWordIndex =
493
- TestState . activeWordIndex - TestState . activeWordElementOffset ;
493
+ TestState . activeWordIndex - TestState . removedUIWordCount ;
494
494
const activeWordEl = wordElements [ activeWordIndex ] ;
495
495
if ( ! activeWordEl ) {
496
496
resolve ( ) ;
@@ -520,7 +520,7 @@ export function updateWordsWrapperHeight(force = false): void {
520
520
) as HTMLElement ;
521
521
const wordElements = wrapperEl . querySelectorAll < HTMLElement > ( "#words .word" ) ;
522
522
const activeWordEl =
523
- wordElements [ TestState . activeWordIndex - TestState . activeWordElementOffset ] ;
523
+ wordElements [ TestState . activeWordIndex - TestState . removedUIWordCount ] ;
524
524
if ( ! activeWordEl ) return ;
525
525
526
526
wrapperEl . classList . remove ( "hidden" ) ;
@@ -642,7 +642,7 @@ export async function updateActiveWordLetters(
642
642
let ret = "" ;
643
643
const activeWord =
644
644
document . querySelectorAll < HTMLElement > ( "#words .word" ) ?. [
645
- TestState . activeWordIndex - TestState . activeWordElementOffset
645
+ TestState . activeWordIndex - TestState . removedUIWordCount
646
646
] ;
647
647
if ( ! activeWord ) return ;
648
648
const hintIndices : number [ ] [ ] = [ ] ;
@@ -832,7 +832,7 @@ export async function scrollTape(noRemove = false): Promise<void> {
832
832
833
833
// index of the active word in the collection of .word elements
834
834
const wordElementIndex =
835
- TestState . activeWordIndex - TestState . activeWordElementOffset ;
835
+ TestState . activeWordIndex - TestState . removedUIWordCount ;
836
836
const wordsWrapperWidth = (
837
837
document . querySelector ( "#wordsWrapper" ) as HTMLElement
838
838
) . offsetWidth ;
@@ -948,10 +948,8 @@ export async function scrollTape(noRemove = false): Promise<void> {
948
948
949
949
/* remove overflown elements */
950
950
if ( toRemove . length > 0 && ! noRemove ) {
951
- TestState . setActiveWordElementOffset (
952
- TestState . activeWordElementOffset + wordsToRemoveCount
953
- ) ;
954
951
for ( const el of toRemove ) el . remove ( ) ;
952
+ TestState . incrementRemovedUIWordCount ( wordsToRemoveCount ) ;
955
953
for ( let i = 0 ; i < widthRemovedFromLine . length ; i ++ ) {
956
954
const afterNewlineEl = afterNewLineEls [ i ] as HTMLElement ;
957
955
const currentLineIndent =
@@ -1071,7 +1069,7 @@ export async function lineJump(
1071
1069
1072
1070
// index of the active word in the collection of .word elements
1073
1071
const wordElementIndex =
1074
- TestState . activeWordIndex - TestState . activeWordElementOffset ;
1072
+ TestState . activeWordIndex - TestState . removedUIWordCount ;
1075
1073
const wordsEl = document . getElementById ( "words" ) as HTMLElement ;
1076
1074
const wordsChildrenArr = [ ...wordsEl . children ] ;
1077
1075
const wordElements = wordsEl . querySelectorAll ( ".word" ) ;
@@ -1146,12 +1144,8 @@ export async function lineJump(
1146
1144
document . querySelectorAll < HTMLElement > ( "#words .word" ) ?. [
1147
1145
wordElementIndex
1148
1146
] ?. offsetTop ?? 0 ;
1149
- TestState . setActiveWordElementOffset (
1150
- TestState . activeWordElementOffset +
1151
- removeElementsBeforeWord (
1152
- lastElementToRemoveIndex ,
1153
- wordsChildrenArr
1154
- )
1147
+ TestState . incrementRemovedUIWordCount (
1148
+ removeElementsBeforeWord ( lastElementToRemoveIndex , wordsChildrenArr )
1155
1149
) ;
1156
1150
wordsEl . style . marginTop = "0" ;
1157
1151
lineTransition = false ;
@@ -1160,9 +1154,8 @@ export async function lineJump(
1160
1154
} ) ;
1161
1155
jqWords . dequeue ( "topMargin" ) ;
1162
1156
} else {
1163
- TestState . setActiveWordElementOffset (
1164
- TestState . activeWordElementOffset +
1165
- removeElementsBeforeWord ( lastElementToRemoveIndex , wordsChildrenArr )
1157
+ TestState . incrementRemovedUIWordCount (
1158
+ removeElementsBeforeWord ( lastElementToRemoveIndex , wordsChildrenArr )
1166
1159
) ;
1167
1160
paceCaretElement . style . top = `${
1168
1161
paceCaretElement . offsetTop - wordHeight
0 commit comments