From 7c274450ac7a3ebc91b498d890255b163036d3b4 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 6 May 2013 18:38:15 +0200 Subject: [PATCH] More Unread scrolling fixes. --- src/Monitoring/Unread.coffee | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 1ff2c20f2..79a4f072b 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -30,6 +30,7 @@ Unread = for ID, post of Unread.thread.posts posts.push post if post.isReply Unread.addPosts posts + return unless Conf['Scroll to Last Read Post'] Unread.scroll() scroll: -> @@ -43,11 +44,15 @@ Unread = break if prevID is post.ID prevID = post.ID break unless post.isHidden - root.scrollIntoView false - return - # Scroll to the last read post. - posts = Object.keys Unread.thread.posts - Header.scrollToPost Unread.thread.posts[posts[posts.length - 1]].nodes.root + onload = -> root.scrollIntoView false + else + # Scroll to the last read post. + posts = Object.keys Unread.thread.posts + post = Unread.thread.posts[posts[posts.length - 1]] + onload = -> Header.scrollToPost post.nodes.root + # Prevent the browser to scroll back to + # the previous scroll location on page load. + $.on window, 'load', onload sync: -> lastReadPost = Unread.db.get