mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 04:51:16 +08:00
Add var, and checks so it doesn't run unless it needs to
This commit is contained in:
parent
cd49d3dc7f
commit
dbf706ca47
1 changed files with 4 additions and 2 deletions
|
@ -16,6 +16,7 @@ let afkDetected = false;
|
|||
let errorsPerSecond = [];
|
||||
let currentErrorCount = 0;
|
||||
let resultVisible = false;
|
||||
let browserHeight = document.documentElement.clientHeight;
|
||||
|
||||
let accuracyStats = {
|
||||
correct: 0,
|
||||
|
@ -371,14 +372,15 @@ function updateCaretPosition() {
|
|||
left: newLeft
|
||||
}, duration)
|
||||
|
||||
let middlePos = (document.documentElement.clientHeight / 2);
|
||||
let middlePos = (browserHeight / 2) - $("#caret").outerHeight()/2;
|
||||
|
||||
if (newTop >= middlePos) {
|
||||
if (newTop >= middlePos && window.innerHeight > browserHeight) {
|
||||
window.scrollTo({
|
||||
left: 0,
|
||||
top: newTop - middlePos,
|
||||
behavior: 'smooth'
|
||||
})
|
||||
console.log("run")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue