diff --git a/4chan_x.user.js b/4chan_x.user.js index 390432caa..e25da3052 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2991,9 +2991,12 @@ } }, toggle: function(a) { - var thumb; + var rect, thumb; thumb = a.firstChild; if (thumb.hidden) { + rect = a.parentNode.getBoundingClientRect(); + 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 1cd6ac8c1..b3f4c73dc 100644 --- a/script.coffee +++ b/script.coffee @@ -2316,6 +2316,9 @@ imgExpand = toggle: (a) -> thumb = a.firstChild if thumb.hidden + rect = a.parentNode.getBoundingClientRect() + 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