From 4d4987a5b006d77d14541a85f09420765ae01cf9 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 13 Feb 2021 19:10:29 +0000 Subject: [PATCH] fixed zen scrolling --- src/js/script.js | 52 +++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/js/script.js b/src/js/script.js index f3f460def..792279e40 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -692,12 +692,14 @@ async function initWords() { } else { $("#words").removeClass("withLigatures"); } - if (config.mode == "zen") { - // Creating an empty active word element for zen mode - $("#words").append('
'); - } else { - showWords(); - } + // if (config.mode == "zen") { + // // Creating an empty active word element for zen mode + // $("#words").append('
'); + // $("#words").css("height", "auto"); + // $("#wordsWrapper").css("height", "auto"); + // } else { + showWords(); + // } } function arrangeCharactersRightToLeft() { @@ -1015,22 +1017,28 @@ function showWords() { let wordsHTML = ""; let newlineafter = false; - for (let i = 0; i < wordsList.length; i++) { - newlineafter = false; - wordsHTML += `
`; - for (let c = 0; c < wordsList[i].length; c++) { - if (wordsList[i].charAt(c) === "\t") { - wordsHTML += ``; - } else if (wordsList[i].charAt(c) === "\n") { - newlineafter = true; - wordsHTML += ``; - } else { - wordsHTML += "" + wordsList[i].charAt(c) + ""; + if (config.mode !== "zen") { + for (let i = 0; i < wordsList.length; i++) { + newlineafter = false; + wordsHTML += `
`; + for (let c = 0; c < wordsList[i].length; c++) { + if (wordsList[i].charAt(c) === "\t") { + wordsHTML += ``; + } else if (wordsList[i].charAt(c) === "\n") { + newlineafter = true; + wordsHTML += ``; + } else { + wordsHTML += "" + wordsList[i].charAt(c) + ""; + } } + wordsHTML += "
"; + if (newlineafter) wordsHTML += "
"; } - wordsHTML += "
"; - if (newlineafter) wordsHTML += "
"; + } else { + wordsHTML = + '
word height
'; } + $("#words").html(wordsHTML); $("#wordsWrapper").removeClass("hidden"); @@ -1060,6 +1068,10 @@ function showWords() { $(".outOfFocusWarning").css("line-height", wordHeight * 3 + "px"); } + if (config.mode === "zen") { + $(document.querySelector(".word")).remove(); + } + if (config.keymapMode === "next") { updateHighlightedKeymapKey(); } @@ -5717,7 +5729,7 @@ function handleAlpha(event) { document.querySelectorAll("#words .word")[currentWordElementIndex - 1] .offsetTop ); - lineJump(currentTop); + if (!config.showAllLines) lineJump(currentTop); } else { currentInput = currentInput.slice(0, -1); updateWordElement(!config.blindMode);