Shave a few lines.
This commit is contained in:
parent
13f7afba63
commit
606cbcc1c1
@ -49,11 +49,8 @@ Unread =
|
|||||||
{root} = Unread.thread.posts[posts[posts.length - 1]].nodes
|
{root} = Unread.thread.posts[posts[posts.length - 1]].nodes
|
||||||
onload = -> Header.scrollToPost root if checkPosition root
|
onload = -> Header.scrollToPost root if checkPosition root
|
||||||
checkPosition = (target) ->
|
checkPosition = (target) ->
|
||||||
# Don't scroll to the target if
|
# Scroll to the target unless we scrolled past it.
|
||||||
# - it's visible.
|
target.getBoundingClientRect().bottom > doc.clientHeight
|
||||||
# - we've scrolled past it.
|
|
||||||
{top, height} = target.getBoundingClientRect()
|
|
||||||
top + height - doc.clientHeight > 0
|
|
||||||
# Prevent the browser to scroll back to
|
# Prevent the browser to scroll back to
|
||||||
# the previous scroll location on page load.
|
# the previous scroll location on page load.
|
||||||
$.on window, 'load', onload
|
$.on window, 'load', onload
|
||||||
@ -136,8 +133,7 @@ Unread =
|
|||||||
return if d.hidden or !Unread.posts.length
|
return if d.hidden or !Unread.posts.length
|
||||||
height = doc.clientHeight
|
height = doc.clientHeight
|
||||||
for post, i in Unread.posts
|
for post, i in Unread.posts
|
||||||
{bottom} = post.nodes.root.getBoundingClientRect()
|
break if post.nodes.root.getBoundingClientRect().bottom > height # post is not completely read
|
||||||
break if bottom > height # post is not completely read
|
|
||||||
return unless i
|
return unless i
|
||||||
|
|
||||||
Unread.lastReadPost = Unread.posts.splice(0, i)[i - 1].ID
|
Unread.lastReadPost = Unread.posts.splice(0, i)[i - 1].ID
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user