Use getBoundingClientRect and body.clientHeight for offset fix

This commit is contained in:
ahodesuka 2012-01-18 19:09:37 -06:00
parent 7a2343f6c5
commit 9baddbc771
2 changed files with 5 additions and 14 deletions

View File

@ -2991,16 +2991,11 @@
} }
}, },
toggle: function(a) { toggle: function(a) {
var el, thumb, top; var thumb, top;
thumb = a.firstChild; thumb = a.firstChild;
if (thumb.hidden) { if (thumb.hidden) {
if (thumb.nextSibling.offsetHeight > window.innerHeight) { if (thumb.nextSibling.offsetHeight > d.body.clientHeight && (top = a.getBoundingClientRect().top) < 0) {
el = thumb.nextSibling; window.scroll(window.scrollX, window.scrollY + top);
top = el.offsetTop;
while (el = el.offsetParent) {
top += el.offsetTop;
}
if (top < window.scrollY) window.scroll(window.scrollX, top);
} }
return imgExpand.contract(thumb); return imgExpand.contract(thumb);
} else { } else {

View File

@ -2316,12 +2316,8 @@ imgExpand =
toggle: (a) -> toggle: (a) ->
thumb = a.firstChild thumb = a.firstChild
if thumb.hidden if thumb.hidden
if thumb.nextSibling.offsetHeight > window.innerHeight if thumb.nextSibling.offsetHeight > d.body.clientHeight and (top = a.getBoundingClientRect().top) < 0
el = thumb.nextSibling window.scroll window.scrollX, window.scrollY + top
top = el.offsetTop
while el = el.offsetParent
top += el.offsetTop
window.scroll window.scrollX, top if top < window.scrollY
imgExpand.contract thumb imgExpand.contract thumb
else else
imgExpand.expand thumb imgExpand.expand thumb