Fix scroll offset when contracting images

This commit is contained in:
ahodesuka 2012-01-17 23:39:38 -06:00
parent 8313c05195
commit 2a1f482e66

View File

@ -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);