Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/jump.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ const jumper = () => {
// element offset helper

function top (element) {
return element.getBoundingClientRect().top + start
// get max scroll value
const windowHeight = (window.innerHeight || document.documentElement.clientHeight);
const documentHeight = document.body.clientHeight;
const max = documentHeight - windowHeight - offset;

// get element scroll top
const top = element.getBoundingClientRect().top + start;

return Math.min(element.getBoundingClientRect().top + start, max);
Comment thread
tristantbg marked this conversation as resolved.
}

// rAF loop helper
Expand Down