impr(tape mode): show next line if test has newlines (@NadAlaba)
Description
-
Added a
div.afterNewlinethat indents next line after eachdiv.newlineelement (ingetWordHTML()andupdateActiveWordLetters()). -
Added
div.beforeNewlinebefore eachdiv.newlineso that when first line in tape mode becomes empty because ofscrollTape()removing overflown words, the second won't jump up while the user is not expecting a line jump (ingetWordHTML()andupdateActiveWordLetters()). -
Changed
#wordsdisplay from flex to block and made.word,.afterNewlineand.beforeNewlineelementsdisplay: inline-block(while keeping.newlineas blocks) in order to usetext-wrap: nowrap, but still be able to break on demand with block elements.newline. Also, make default.wordmargin-bottom in tape mode 0.25em just like in non-tape mode, since they are now practically similar. -
Made default
#wordsWrapperheight: autobutmax-heighis 3 lines in tape mode and non tape mode. -
Calculate wordsInput left position in tape mode + zen mode + RTL just like with no tape mode.
-
In
scrollTape():- Remove leading
.afterNewlineelements. - Get last element to loop over which is the 2nd
.afterNewlineafter active word, or else the 1st one after active, or else stop at the active word. - In the loop sum the widths of words before new line then add it to the left margin of the next
.afterNewline, while also determining the widths of words before the active word (which will be in the new margin-left of#words), and determine what words have overflown the wrapper and need to be hidden. - If requested (through
noRemoveparameter) don't remove elements until after the margins are set. - If there is anything to hide, hide the elements, and adjust margin-left of
#wordsand.afterNewlineby the width of what was hidden - Calculate the width of the current word in tape=letter just like before then animate the new
#wordsmargin-left and.afterNewlineelements' margin-left. - The
#wordsmargin-left animation is done in its own queue so that when we use.stop()before the animation we'll only be stopping the margin-left animation and not the margin-top animation which is performed inlineJump().
- Remove leading
-
In
lineJump():- Some refactoring: save HTMLelements in const instead of repeatedly querying the DOM.
- The conditions to run
lineJump()are now similar in tapeMode on and off (currentTestLine > 0, hideBound = currentTop - 10). - When determining the elements to hide, save the last element to hide in a const and then remove everything before it. It is done like this instead of saving what needs to be hidden in an array, because
.afterNewlineelements have offsetTops that cannot be relied upon to determine if they need to be hidden or not. The new functionremoveElementsBeforeWord()does that (removes all elements before lastElementToRemove (included) and returns removed.words count). lastElementToHideis now the last.wordor.newlinethat is higher than thehideBound.#wordsmargin-top animation is done in its own queue so that we only.stop()margin-top animation without affecting margin-left animation.
-
Now, Config.showAllLines can be changed without restarting test.
-
updateTestLine()(a new function that determines what line to jump to) now runslineJump()in force (even when currentTestLine === 0), which is useful to update test line when changing Config.showAllLines to off -
Previously, when show all lines was on and tape mode was turned on through the commandline mid-test, lineJump() (which ran because of the automatic change of showAllLines to off) would remove some elements conflicting with tape mode removing elements too. That's why each time this scenario happens allowWordRemoval (a new global variable) would be set to false, and if it is false and lineTransition is true, scrollTape() would not do anything (remove words or set #words.marginLeft) until lineJump finishes removing elements.
Closes #3907
This PR is stale. Please trigger a re-run of the PR check action.
This PR is stale. Please trigger a re-run of the PR check action.
This PR is stale. Please trigger a re-run of the PR check action.
Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes.