Skip to content

Commit cd49d3d

Browse files
committed
Scroll Longform text
1 parent c2629c6 commit cd49d3d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

public/js/script.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,16 @@ function updateCaretPosition() {
371371
left: newLeft
372372
}, duration)
373373

374+
let middlePos = (document.documentElement.clientHeight / 2);
375+
376+
if (newTop >= middlePos) {
377+
window.scrollTo({
378+
left: 0,
379+
top: newTop - middlePos,
380+
behavior: 'smooth'
381+
})
382+
}
383+
374384
}
375385

376386
function countChars() {

0 commit comments

Comments
 (0)