Better image contracting repositioning.
It will scroll depending on the position of the post after contracting instead of the position of the image before contracting.
This commit is contained in:
parent
140aca5460
commit
e63b0705d3
@ -3233,20 +3233,16 @@ ImageExpand =
|
|||||||
unless post.file.isExpanded or $.hasClass thumb, 'expanding'
|
unless post.file.isExpanded or $.hasClass thumb, 'expanding'
|
||||||
ImageExpand.expand post
|
ImageExpand.expand post
|
||||||
return
|
return
|
||||||
rect = thumb.parentNode.getBoundingClientRect()
|
|
||||||
if rect.bottom > 0 # Should be at least partially visible.
|
|
||||||
# Scroll back to the thumbnail when contracting the image
|
|
||||||
# to avoid being left miles away from the relevant post.
|
|
||||||
postRect = post.nodes.root.getBoundingClientRect()
|
|
||||||
headRect = Header.toggle.getBoundingClientRect()
|
|
||||||
top = postRect.top - headRect.top - headRect.height - 2
|
|
||||||
root = if $.engine is 'webkit'
|
|
||||||
d.body
|
|
||||||
else
|
|
||||||
doc
|
|
||||||
root.scrollTop += top if rect.top < 0
|
|
||||||
root.scrollLeft = 0 if rect.left < 0
|
|
||||||
ImageExpand.contract post
|
ImageExpand.contract post
|
||||||
|
rect = post.nodes.root.getBoundingClientRect()
|
||||||
|
return unless rect.top <= 0 or rect.left <= 0
|
||||||
|
# Scroll back to the thumbnail when contracting the image
|
||||||
|
# to avoid being left miles away from the relevant post.
|
||||||
|
headRect = Header.toggle.getBoundingClientRect()
|
||||||
|
top = rect.top - headRect.top - headRect.height
|
||||||
|
root = if $.engine is 'webkit' then d.body else doc
|
||||||
|
root.scrollTop += top if rect.top < 0
|
||||||
|
root.scrollLeft = 0 if rect.left < 0
|
||||||
|
|
||||||
contract: (post) ->
|
contract: (post) ->
|
||||||
$.rmClass post.nodes.root, 'expanded-image'
|
$.rmClass post.nodes.root, 'expanded-image'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user