From e4f428efebf557eed14ea8f4f4fba4d5591f4870 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 30 Mar 2013 05:08:12 +0100 Subject: [PATCH] Better image expanding repositioning. Images that get unsquashed have their .top changed, so it should adjust to that too. --- src/features.coffee | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/features.coffee b/src/features.coffee index 5f32af041..934b5f363 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -3271,16 +3271,14 @@ ImageExpand = completeExpand: (post) -> {thumb} = post.file return unless $.hasClass thumb, 'expanding' # contracted before the image loaded - rect = post.nodes.root.getBoundingClientRect() + prev = post.nodes.root.getBoundingClientRect() + post.file.isExpanded = true $.addClass post.nodes.root, 'expanded-image' $.rmClass post.file.thumb, 'expanding' - if rect.top + rect.height <= 0 - root = if $.engine is 'webkit' - d.body - else - doc - root.scrollTop += post.nodes.root.clientHeight - rect.height - post.file.isExpanded = true + return unless prev.top + prev.height <= 0 + root = if $.engine is 'webkit' then d.body else doc + curr = post.nodes.root.getBoundingClientRect() + root.scrollTop += curr.height - prev.height + curr.top - prev.top error: -> post = Get.postFromNode @