Commit 5ca47e1
impr(tape mode): support RTL languages (@nadalaba) (monkeytypegame#5748)
### Description
1. Support RTL in tape mode:
- In `scrollTape()`: flip the sign of `#words.margin-left` and add
`.word.margin-right` to center first letter in RTL.
- In `Caret.getTargetPositionLeft()`: flip the direction of tapeMargin
in RTL.
- Remove restriction on RTL tape mode from test-logic.ts.
2. Support zero-width characters in tape mode:
- Subtract the width of the last letter that has a positive width if the
current letter has a zero width (e.g, diacritics). This is needed when
calculation is based on letter widths instead of letter position, which
is done in caret.ts when tape=word, and in `scrollTape()` when
tape=letter.
3. Remove the width change of `#words` in tape mode to 200vw because
it's not needed anymore now that we're using `white-space: nowrap`:
- Also adjust the limit of `.afterNewline.margin-left` to be 3 times the
new width of `#words` which is now equal to `#wordsWrapper.width` by
default.
4. Make `.word.height` in `.withLigature` langs similar to their height
in english:
- Imitate the appearance and behavior of `inline-block` `<letter>`s in
`.withLigatures` lanuages. These languages make the display of
`<letter>` elements `inline` in order to allow the joining of letters.
However, this causes `<letter>`'s `border-bottom` to be ignored, which
changes `.word` height, so we add a `padding-bottom` to the `.word` in
that case.
- Also, `inline` `<letter>`s overflow the `#wordWrapper` without
wrapping (e.g, when `maxLineWidth` = 20ch and we type 30 letters), so we
add the property `overflow-wrap: anywhere`, but we don't allow `.hints`
to inherit this property.
- P.S, it is necessary that all `.word`s have the same height (with and
without ligatures), because we now set the height of `.beforeNewline`s
in css, and we depend on these elements to have the same height as
`.word`s so that the user won't feel a vertical shift in lines in tape
mode.
5. Animate turning off tape mode in `updateWordsMargin()` if
`SmoothLineScroller` is on.
6. Block removing words at the first call of `scrollTape()`:
- Because the inline style of `#words.margin-left` may be negative when
restarting the test, making `scrollTape()` start when the first word is
overflown to the left, which makes `scrollTape()` remove that word (this
bug affects LTR and RTL langs).
closes monkeytypegame#3923
---------
Co-authored-by: Jack <[email protected]>1 parent 85543ff commit 5ca47e1
File tree
4 files changed
+106
-42
lines changed- frontend/src
- styles
- ts/test
4 files changed
+106
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
300 | 299 | | |
301 | 300 | | |
302 | 301 | | |
| |||
314 | 313 | | |
315 | 314 | | |
316 | 315 | | |
317 | | - | |
318 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
319 | 331 | | |
320 | 332 | | |
321 | 333 | | |
| |||
743 | 755 | | |
744 | 756 | | |
745 | 757 | | |
746 | | - | |
747 | | - | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
748 | 769 | | |
749 | 770 | | |
750 | 771 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | | - | |
121 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
122 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
123 | 133 | | |
124 | 134 | | |
125 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | 458 | | |
466 | 459 | | |
467 | 460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| 416 | + | |
416 | 417 | | |
417 | 418 | | |
418 | 419 | | |
419 | | - | |
420 | | - | |
421 | 420 | | |
422 | 421 | | |
423 | 422 | | |
| |||
598 | 597 | | |
599 | 598 | | |
600 | 599 | | |
601 | | - | |
| 600 | + | |
602 | 601 | | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
607 | 626 | | |
608 | 627 | | |
609 | 628 | | |
| |||
816 | 835 | | |
817 | 836 | | |
818 | 837 | | |
819 | | - | |
| 838 | + | |
820 | 839 | | |
821 | 840 | | |
822 | 841 | | |
823 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
824 | 846 | | |
825 | 847 | | |
826 | 848 | | |
| |||
898 | 920 | | |
899 | 921 | | |
900 | 922 | | |
901 | | - | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
902 | 927 | | |
903 | 928 | | |
904 | 929 | | |
| |||
912 | 937 | | |
913 | 938 | | |
914 | 939 | | |
915 | | - | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
916 | 946 | | |
917 | 947 | | |
918 | 948 | | |
919 | | - | |
| 949 | + | |
920 | 950 | | |
921 | 951 | | |
922 | 952 | | |
923 | | - | |
| 953 | + | |
924 | 954 | | |
925 | 955 | | |
926 | 956 | | |
| |||
929 | 959 | | |
930 | 960 | | |
931 | 961 | | |
932 | | - | |
| 962 | + | |
933 | 963 | | |
934 | 964 | | |
935 | 965 | | |
| |||
940 | 970 | | |
941 | 971 | | |
942 | 972 | | |
| 973 | + | |
943 | 974 | | |
944 | 975 | | |
945 | 976 | | |
946 | 977 | | |
947 | 978 | | |
948 | 979 | | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
961 | 991 | | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
962 | 995 | | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
963 | 999 | | |
| 1000 | + | |
964 | 1001 | | |
965 | | - | |
966 | | - | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
967 | 1007 | | |
968 | 1008 | | |
969 | 1009 | | |
| |||
0 commit comments