@@ -967,27 +967,32 @@ export function scrollTape(): void {
967
967
let widthToHide = 0 ;
968
968
let wordsToHideCount = 0 ;
969
969
let leadingNewLine = 0 ;
970
+ let lastAfterNewLineElement = undefined ;
970
971
const linesWidths : number [ ] = [ ] ;
971
972
const toHide : HTMLElement [ ] = [ ] ;
972
973
973
974
// remove leading `.newline` and `.afterNewline` elements
974
975
for ( const child of wordsChildrenArr ) {
975
976
if ( child . classList . contains ( "word" ) ) {
977
+ // only last leading `.afterNewline` element pushes `.word`s to right
978
+ if ( lastAfterNewLineElement ) {
979
+ widthToHide += parseInt ( lastAfterNewLineElement . style . marginLeft ) ;
980
+ }
976
981
break ;
977
982
} else if ( child . classList . contains ( "newline" ) ) {
978
983
toHide . push ( child ) ;
979
984
} else if ( child . classList . contains ( "afterNewline" ) ) {
980
985
toHide . push ( child ) ;
981
- widthToHide += parseInt ( child . style . marginLeft ) ;
982
986
leadingNewLine = 1 ;
987
+ lastAfterNewLineElement = child ;
983
988
}
984
989
}
985
990
// get last element to loop over
986
991
const activeWordIndex = wordsChildrenArr . indexOf ( activeWordEl ) ;
987
992
const newLinesBeforeActiveWord = wordsChildrenArr
988
993
. slice ( 0 , activeWordIndex )
989
994
. filter ( ( child ) => child . classList . contains ( "afterNewline" ) ) . length ;
990
- // the second .afterNewline after active word is visible during line jump
995
+ // the second ` .afterNewline` after active word is visible during line jump
991
996
let lastVisibleAfterNewline = afterNewLineEls [
992
997
newLinesBeforeActiveWord + 1
993
998
] as HTMLElement | undefined ;
0 commit comments