From 186a7e6a5acef962e6bf3784947e1d0fb9e469e1 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 24 Apr 2013 15:14:31 -0700 Subject: [PATCH] Fix our ImageExpand scrolling. --- builds/4chan-X.js | 7 +++++-- builds/4chan-X.user.js | 7 +++++-- builds/crx/script.js | 7 +++++-- src/features/imaging/imageexpand.coffee | 9 +++++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/builds/4chan-X.js b/builds/4chan-X.js index c79fbe19c..af7489afd 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -3264,8 +3264,11 @@ if (!(rect.top <= 0 || rect.left <= 0)) { return; } - headRect = Header.bar.getBoundingClientRect(); - top = rect.top - headRect.top - headRect.height; + top = rect.top; + if (Conf['Fixed Header'] && !Conf['Bottom Header']) { + headRect = Header.bar.getBoundingClientRect(); + top += -headRect.top - headRect.height; + } root = doc; if (rect.top < 0) { root.scrollTop += top; diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 40873bc22..a44f22104 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -3255,8 +3255,11 @@ if (!(rect.top <= 0 || rect.left <= 0)) { return; } - headRect = Header.bar.getBoundingClientRect(); - top = rect.top - headRect.top - headRect.height; + top = rect.top; + if (Conf['Fixed Header'] && !Conf['Bottom Header']) { + headRect = Header.bar.getBoundingClientRect(); + top += -headRect.top - headRect.height; + } root = doc; if (rect.top < 0) { root.scrollTop += top; diff --git a/builds/crx/script.js b/builds/crx/script.js index f8b64119c..b926cf861 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -3119,8 +3119,11 @@ if (!(rect.top <= 0 || rect.left <= 0)) { return; } - headRect = Header.bar.getBoundingClientRect(); - top = rect.top - headRect.top - headRect.height; + top = rect.top; + if (Conf['Fixed Header'] && !Conf['Bottom Header']) { + headRect = Header.bar.getBoundingClientRect(); + top += -headRect.top - headRect.height; + } root = d.body; if (rect.top < 0) { root.scrollTop += top; diff --git a/src/features/imaging/imageexpand.coffee b/src/features/imaging/imageexpand.coffee index 240839fbd..87eb99755 100644 --- a/src/features/imaging/imageexpand.coffee +++ b/src/features/imaging/imageexpand.coffee @@ -71,10 +71,11 @@ ImageExpand = 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.bar.getBoundingClientRect() - top = rect.top - headRect.top - headRect.height + {top} = rect + if Conf['Fixed Header'] and not Conf['Bottom Header'] + headRect = Header.bar.getBoundingClientRect() + top += - headRect.top - headRect.height + root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %> root.scrollTop += top if rect.top < 0