Made Scroll to Last Read Post optional. Close #1009
Fix a bug where it attempted to scroll to a hidden post without stub, effectively scrolling to the end of the thread.
This commit is contained in:
parent
f4bf9b5413
commit
344e1aaa19
@ -1,3 +1,4 @@
|
|||||||
|
- `Scroll to Last Read Post` is now optional, enabled by default.
|
||||||
- The QR won't auto-hide when auto-hide is enabled and one of its input is focused. Doesn't work on Firefox.
|
- The QR won't auto-hide when auto-hide is enabled and one of its input is focused. Doesn't work on Firefox.
|
||||||
- Fix QR remembering the file spoiler state when it shouldn't.
|
- Fix QR remembering the file spoiler state when it shouldn't.
|
||||||
- Fix QR cooldown in Opera.
|
- Fix QR cooldown in Opera.
|
||||||
|
|||||||
@ -39,6 +39,7 @@ Config =
|
|||||||
'Unread Count': [true, 'Show the unread posts count in the tab title.']
|
'Unread Count': [true, 'Show the unread posts count in the tab title.']
|
||||||
'Unread Tab Icon': [true, 'Show a different favicon when there are unread posts.']
|
'Unread Tab Icon': [true, 'Show a different favicon when there are unread posts.']
|
||||||
'Unread Line': [true, 'Show a line to distinguish read posts from unread ones.']
|
'Unread Line': [true, 'Show a line to distinguish read posts from unread ones.']
|
||||||
|
'Scroll to Last Read Post': [true, 'Scroll back to the last read post when reopening a thread.']
|
||||||
'Thread Excerpt': [true, 'Show an excerpt of the thread in the tab title.']
|
'Thread Excerpt': [true, 'Show an excerpt of the thread in the tab title.']
|
||||||
'Thread Stats': [true, 'Display reply and image count.']
|
'Thread Stats': [true, 'Display reply and image count.']
|
||||||
'Thread Watcher': [true, 'Bookmark threads.']
|
'Thread Watcher': [true, 'Bookmark threads.']
|
||||||
|
|||||||
@ -160,6 +160,7 @@ Header =
|
|||||||
(if hide then $.addClass else $.rmClass) Header.bar, 'autohide'
|
(if hide then $.addClass else $.rmClass) Header.bar, 'autohide'
|
||||||
hashScroll: ->
|
hashScroll: ->
|
||||||
return unless post = $.id @location.hash[1..]
|
return unless post = $.id @location.hash[1..]
|
||||||
|
return if (Get.postFromRoot post).isHidden
|
||||||
Header.scrollToPost post
|
Header.scrollToPost post
|
||||||
scrollToPost: (post) ->
|
scrollToPost: (post) ->
|
||||||
{top} = post.getBoundingClientRect()
|
{top} = post.getBoundingClientRect()
|
||||||
@ -3709,18 +3710,22 @@ Unread =
|
|||||||
threadID: @ID
|
threadID: @ID
|
||||||
defaultValue: 0
|
defaultValue: 0
|
||||||
Unread.addPosts posts
|
Unread.addPosts posts
|
||||||
if (hash = location.hash.match /\d+/) and post = @posts[hash[0]]
|
|
||||||
Header.scrollToPost post.nodes.root
|
|
||||||
else if Unread.posts.length
|
|
||||||
# Scroll to before the first unread post.
|
|
||||||
$.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root).scrollIntoView false
|
|
||||||
else if posts.length
|
|
||||||
# Scroll to the last read post.
|
|
||||||
Header.scrollToPost posts[posts.length - 1].nodes.root
|
|
||||||
$.on d, 'ThreadUpdate', Unread.onUpdate
|
$.on d, 'ThreadUpdate', Unread.onUpdate
|
||||||
$.on d, 'scroll visibilitychange', Unread.read
|
$.on d, 'scroll visibilitychange', Unread.read
|
||||||
$.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
|
$.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
|
||||||
|
|
||||||
|
return unless Conf['Scroll to Last Read Post']
|
||||||
|
# Let the header's onload callback handle it.
|
||||||
|
return if (hash = location.hash.match /\d+/) and hash[0] of @posts
|
||||||
|
if Unread.posts.length
|
||||||
|
# Scroll to before the first unread post.
|
||||||
|
while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root
|
||||||
|
break unless (Get.postFromRoot root).isHidden
|
||||||
|
root.scrollIntoView false
|
||||||
|
else if posts.length
|
||||||
|
# Scroll to the last read post.
|
||||||
|
Header.scrollToPost posts[posts.length - 1].nodes.root
|
||||||
|
|
||||||
sync: ->
|
sync: ->
|
||||||
lastReadPost = Unread.db.get
|
lastReadPost = Unread.db.get
|
||||||
boardID: Unread.thread.board.ID
|
boardID: Unread.thread.board.ID
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user