From 7d38f0502c136d5c02b6a3b0e9483859eb98b196 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 8 Jul 2013 23:40:48 +0200 Subject: [PATCH] More thoughtful unread-scroll code. --- src/Monitoring/Unread.coffee | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 6ad07f03e..34ad6180a 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -37,13 +37,11 @@ Unread = # Let the header's onload callback handle it. return if (hash = location.hash.match /\d+/) and hash[0] of Unread.thread.posts if Unread.posts.length - # Scroll to before the first unread post. - {root} = Unread.posts[0].nodes - while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', root - post = Get.postFromRoot root - # Don't scroll if we have 0 posts read in this thread. - return unless post.isReply - break unless post.isHidden + # Scroll to a non-hidden, non-OP post that's before the first unread post. + post = Unread.posts[0] + while root = $.x 'preceding-sibling::div[contains(@class,"replyContainer")][1]', post.nodes.root + break unless (post = Get.postFromRoot root).isHidden + return unless root onload = -> root.scrollIntoView false if checkPosition root else # Scroll to the last read post.