Fix jumping between boxes
This commit is contained in:
parent
9ce2e08810
commit
1201803168
|
@ -18,13 +18,14 @@
|
|||
<script>
|
||||
const textEl = document.getElementById("text");
|
||||
const textExtEl = document.getElementById("extended_text");
|
||||
textEl.addEventListener("keypressed", evt => {
|
||||
textEl.addEventListener("keydown", evt => {
|
||||
// If the length is more than 120
|
||||
const value = textEl.value;
|
||||
if (value.length > 120) {
|
||||
const toMove = value.substring(value.lastIndexOf(" ") + 1); //Plus 1 trims the space
|
||||
if (value.length > 140) {
|
||||
const splitAt = value.lastIndexOf(" ", 140) + 1; // Plus 1 keeps the space in the original text instead of moving it
|
||||
const toMove = value.substring(splitAt);
|
||||
textExtEl.value = toMove + textExtEl.value;
|
||||
textEl.value = value.substring(0, value.lastIndexOf(" ") + 1)// Plus 1 keeps the space
|
||||
textEl.value = value.substring(0, splitAt);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue