Merge pull request #80 from bhomie:long-text-scroll

Scroll Longform text
This commit is contained in:
Jack 2020-05-29 14:01:37 +01:00 committed by GitHub
commit e74cb09553
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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() {