Scroll the reply to the bottom of the window; scroll only if the last reply is mostly visible, not when we're at the bottom; fix previousElementSibling, apparently it doesn't work on every boards.

This commit is contained in:
Nicolas Stepien 2011-10-16 17:51:19 +02:00
parent 0383a3629a
commit f9c36d4704
2 changed files with 7 additions and 6 deletions

View File

@ -1994,12 +1994,12 @@
return;
}
replies = $$('.reply', body);
id = Number(((_ref2 = $('td[id]', updater.br.previousSibling)) != null ? _ref2.id : void 0) || 0);
id = Number(((_ref2 = $('td[id]', updater.br.previousElementSibling)) != null ? _ref2.id : void 0) || 0);
arr = [];
while ((reply = replies.pop()) && (reply.id > id)) {
arr.push(reply.parentNode.parentNode.parentNode);
}
scroll = conf['Scrolling'] && updater.scrollBG() && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20);
scroll = conf['Scrolling'] && updater.scrollBG() && arr.length && updater.br.previousElementSibling.getBoundingClientRect().bottom - d.body.clientHeight < 25;
if (conf['Verbose']) {
updater.count.textContent = '+' + arr.length;
if (arr.length === 0) {
@ -2012,7 +2012,7 @@
$.before(updater.br, reply);
}
if (scroll) {
return updater.br.previousSibling.scrollIntoView();
return updater.br.previousSibling.scrollIntoView(false);
}
}
},

View File

@ -1516,12 +1516,13 @@ updater =
return
replies = $$ '.reply', body
id = Number $('td[id]', updater.br.previousSibling)?.id or 0
id = Number $('td[id]', updater.br.previousElementSibling)?.id or 0
arr = []
while (reply = replies.pop()) and (reply.id > id)
arr.push reply.parentNode.parentNode.parentNode #table
scroll = conf['Scrolling'] && updater.scrollBG() && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20)
scroll = conf['Scrolling'] && updater.scrollBG() && arr.length &&
updater.br.previousElementSibling.getBoundingClientRect().bottom - d.body.clientHeight < 25
if conf['Verbose']
updater.count.textContent = '+' + arr.length
if arr.length is 0
@ -1533,7 +1534,7 @@ updater =
while reply = arr.pop()
$.before updater.br, reply
if scroll
updater.br.previousSibling.scrollIntoView()
updater.br.previousSibling.scrollIntoView(false)
timeout: ->
updater.timeoutID = setTimeout updater.timeout, 1000