mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 04:51:16 +08:00
Merge pull request #80 from bhomie:long-text-scroll
Scroll Longform text
This commit is contained in:
commit
e74cb09553
1 changed files with 12 additions and 0 deletions
|
@ -371,6 +371,18 @@ function updateCaretPosition() {
|
|||
left: newLeft
|
||||
}, duration)
|
||||
|
||||
let browserHeight = window.innerHeight;
|
||||
let middlePos = (browserHeight / 2) - $("#caret").outerHeight()/2;
|
||||
let contentHeight = document.body.scrollHeight;
|
||||
|
||||
if (newTop >= middlePos && contentHeight > browserHeight) {
|
||||
window.scrollTo({
|
||||
left: 0,
|
||||
top: newTop - middlePos,
|
||||
behavior: 'smooth'
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function countChars() {
|
||||
|
|
Loading…
Reference in a new issue