From c00dfc238518d9a08823c34ee567c8cf56671fb2 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 27 Sep 2021 00:00:48 +0100 Subject: [PATCH] only checking active word when needed --- src/js/input-controller.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/js/input-controller.js b/src/js/input-controller.js index f25f60cb1..f8892b178 100644 --- a/src/js/input-controller.js +++ b/src/js/input-controller.js @@ -806,23 +806,25 @@ function handleAlpha(event) { }); } - let newActiveTop = document.querySelector("#words .word.active").offsetTop; - //stop the word jump by slicing off the last character, update word again - if ( - activeWordTopBeforeJump < newActiveTop && - !TestUI.lineTransition && - TestLogic.input.current.length > 1 - ) { - if (Config.mode == "zen") { - let currentTop = Math.floor( - document.querySelectorAll("#words .word")[ - TestUI.currentWordElementIndex - 1 - ].offsetTop - ); - if (!Config.showAllLines) TestUI.lineJump(currentTop); - } else { - TestLogic.input.setCurrent(TestLogic.input.current.slice(0, -1)); - TestUI.updateWordElement(!Config.blindMode); + if (!Config.hideExtraLetters) { + let newActiveTop = document.querySelector("#words .word.active").offsetTop; + //stop the word jump by slicing off the last character, update word again + if ( + activeWordTopBeforeJump < newActiveTop && + !TestUI.lineTransition && + TestLogic.input.current.length > 1 + ) { + if (Config.mode == "zen") { + let currentTop = Math.floor( + document.querySelectorAll("#words .word")[ + TestUI.currentWordElementIndex - 1 + ].offsetTop + ); + if (!Config.showAllLines) TestUI.lineJump(currentTop); + } else { + TestLogic.input.setCurrent(TestLogic.input.current.slice(0, -1)); + TestUI.updateWordElement(!Config.blindMode); + } } } if (originalEvent.code !== "Enter") Caret.updatePosition();