@@ -938,7 +938,7 @@ export async function scrollTape(): Promise<void> {
938
938
document . getElementById ( "wordsWrapper" ) as HTMLElement
939
939
) . offsetWidth ;
940
940
const words = document . getElementById ( "words" ) as HTMLElement ;
941
- const wordElements = words . querySelectorAll ( ". word") ;
941
+ const wordElements = words . getElementsByClassName ( " word") ;
942
942
943
943
let fullWordsWidth = 0 ;
944
944
let widthToHide = 0 ;
@@ -958,13 +958,22 @@ export async function scrollTape(): Promise<void> {
958
958
widthToHide += wordOuterWidth ;
959
959
}
960
960
}
961
+ if ( toHide . length > 0 ) {
962
+ currentWordElementIndex -= toHide . length ;
963
+ toHide . forEach ( ( e ) => e . remove ( ) ) ;
964
+ fullWordsWidth -= widthToHide ;
965
+ if ( isLanguageRTL ) widthToHide *= - 1 ;
966
+ const currentMargin = parseInt ( $ ( words ) . css ( "margin-left" ) , 10 ) ;
967
+ words . style . marginLeft = `${ currentMargin + widthToHide } px` ;
968
+ }
969
+ const inputLength = TestInput . input . current . length ;
961
970
let currentWordWidth = 0 ;
962
- if ( Config . tapeMode === "letter" && TestInput . input . current . length > 0 ) {
971
+ if ( Config . tapeMode === "letter" && inputLength > 0 ) {
963
972
const letters =
964
973
wordElements [ currentWordElementIndex ] ?. querySelectorAll ( "letter" ) ;
965
974
if ( ! letters ) return ;
966
975
let lastPositiveLetterWidth = 0 ;
967
- for ( let i = 0 ; i < TestInput . input . current . length ; i ++ ) {
976
+ for ( let i = 0 ; i < inputLength ; i ++ ) {
968
977
const letter = letters [ i ] as HTMLElement ;
969
978
if (
970
979
( Config . blindMode || Config . hideExtraLetters ) &&
@@ -977,10 +986,7 @@ export async function scrollTape(): Promise<void> {
977
986
if ( letterOuterWidth > 0 ) lastPositiveLetterWidth = letterOuterWidth ;
978
987
}
979
988
// if current letter has zero width move the tape to previous positive width letter
980
- if (
981
- $ ( letters [ TestInput . input . current . length ] as Element ) . outerWidth ( true ) ===
982
- 0
983
- )
989
+ if ( $ ( letters [ inputLength ] as Element ) . outerWidth ( true ) === 0 )
984
990
currentWordWidth -= lastPositiveLetterWidth ;
985
991
}
986
992
@@ -1000,17 +1006,7 @@ export async function scrollTape(): Promise<void> {
1000
1006
{
1001
1007
marginLeft : newMargin ,
1002
1008
} ,
1003
- {
1004
- duration : SlowTimer . get ( ) ? 0 : 125 ,
1005
- complete : ( ) => {
1006
- if ( ! toHide . length ) return ;
1007
- currentWordElementIndex -= toHide . length ;
1008
- toHide . forEach ( ( e ) => e . remove ( ) ) ;
1009
- fullWordsWidth -= widthToHide ;
1010
- if ( isLanguageRTL ) widthToHide *= - 1 ;
1011
- words . style . marginLeft = `${ newMargin + widthToHide } px` ;
1012
- } ,
1013
- }
1009
+ SlowTimer . get ( ) ? 0 : 125
1014
1010
) ;
1015
1011
} else {
1016
1012
words . style . marginLeft = `${ newMargin } px` ;
0 commit comments