From 8e2f9167fbc440a58b746131ec09b821e7b31fb4 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 26 Jul 2014 23:57:13 -0700 Subject: [PATCH] scroll so that full image/video is on screen after expansion --- src/Images/ImageExpand.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 4216c6e45..dd72c17c8 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -178,6 +178,12 @@ ImageExpand = # Scroll to keep our place in the thread when images are expanded above us. if oldBottom? and oldBottom <= 0 window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - oldBottom + return + + # Scroll to display full image. + imageBottom = Header.getBottomOf file.fullImage + if imageBottom < 0 + window.scrollBy 0, Math.min(-imageBottom, Header.getTopOf file.fullImage) play: (post) -> if !d.hidden and Header.isNodeVisible post.file.fullImage