From efc557cb1dd6fa3d9fad97bf50c316e441d0759e Mon Sep 17 00:00:00 2001 From: ahodesuka Date: Thu, 19 Jan 2012 10:15:07 -0600 Subject: [PATCH] Scroll to top of thumbnail when contracting expanded image --- 4chan_x.user.js | 8 ++------ script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fa37d7b68..cf7704076 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2995,12 +2995,8 @@ thumb = a.firstChild; if (thumb.hidden) { rect = a.getBoundingClientRect(); - if (rect.top < 0) { - d.body.scrollTop += rect.top + thumb.height / (rect.height / rect.top * -1); - } - if (rect.left < 0) { - d.body.scrollLeft += rect.left + thumb.width / (rect.width / rect.left * -1); - } + if (rect.top < 0) d.body.scrollTop += rect.top; + if (rect.left < 0) d.body.scrollLeft += rect.left; return imgExpand.contract(thumb); } else { return imgExpand.expand(thumb); diff --git a/script.coffee b/script.coffee index 25be94ca4..c5e22e0bf 100644 --- a/script.coffee +++ b/script.coffee @@ -2317,8 +2317,8 @@ imgExpand = thumb = a.firstChild if thumb.hidden rect = a.getBoundingClientRect() - d.body.scrollTop += rect.top + thumb.height / (rect.height / rect.top * -1) if rect.top < 0 - d.body.scrollLeft += rect.left + thumb.width / (rect.width / rect.left * -1) if rect.left < 0 + d.body.scrollTop += rect.top if rect.top < 0 + d.body.scrollLeft += rect.left if rect.left < 0 imgExpand.contract thumb else imgExpand.expand thumb