diff --git a/4chan_x.user.js b/4chan_x.user.js index 6f59cf6ff..71db82528 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2960,7 +2960,7 @@ _results2 = []; for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { thumb = _ref2[_j]; - _results2.push(imgExpand.contract(thumb)); + _results2.push(imgExpand.contract(thumb, false)); } return _results2; } @@ -2994,13 +2994,23 @@ var thumb; thumb = a.firstChild; if (thumb.hidden) { - return imgExpand.contract(thumb); + return imgExpand.contract(thumb, true); } else { return imgExpand.expand(thumb); } }, - contract: function(thumb) { + contract: function(thumb, bScroll) { thumb.hidden = false; + if (bScroll) { + var el, top; + el = thumb.parentNode.parentNode; + top = el.offsetTop; + while (el.offsetParent) { + el = el.offsetParent; + top += el.offsetTop; + } + if (top < window.scrollY) window.scroll(window.scrollX, top); + } return $.rm(thumb.nextSibling); }, expand: function(thumb, url) { @@ -3021,7 +3031,7 @@ error: function() { var req, src, thumb, url; thumb = this.previousSibling; - imgExpand.contract(thumb); + imgExpand.contract(thumb, true); src = this.src.split('/'); if (url = redirect.image(src[3], src[5])) { return imgExpand.expand(thumb, url);