From ae8e1c222552e62f07e0cc817398c35386adf36c Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 31 Dec 2014 00:12:13 -0800 Subject: [PATCH] Fix short threads at the bottom of the page not being selectable by keybinds. #265 --- src/Miscellaneous/Nav.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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