diff --git a/src/Miscellaneous/Nav.coffee b/src/Miscellaneous/Nav.coffee index 659cce4e1..82eeed469 100755 --- a/src/Miscellaneous/Nav.coffee +++ b/src/Miscellaneous/Nav.coffee @@ -58,4 +58,19 @@ Nav = # or we're above the first thread and don't want to skip it. top = Header.getTopOf thread thread = next if delta is +1 and top < 5 or delta is -1 and top > -5 + # Add extra space to the end of the page if necessary so that all threads can be selected by keybinds. + extra = Header.getTopOf(thread) + doc.clientHeight - d.body.getBoundingClientRect().bottom + d.body.style.marginBottom = "#{extra}px" if extra > 0 Header.scrollTo thread + if extra > 0 and !Nav.haveExtra + Nav.haveExtra = true + $.on d, 'scroll', Nav.removeExtra + + removeExtra: -> + extra = doc.clientHeight - d.body.getBoundingClientRect().bottom + if extra > 0 + d.body.style.marginBottom = "#{extra}px" + else + d.body.style.marginBottom = null + delete Nav.haveExtra + $.off d, 'scroll', Nav.removeExtra