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) {
var el, thumb, top;
var thumb, top;
thumb = a.firstChild;
if (thumb.hidden) {
if (thumb.nextSibling.offsetHeight > window.innerHeight) {
el = thumb.nextSibling;
top = el.offsetTop;
while (el = el.offsetParent) {
top += el.offsetTop;
}
if (top < window.scrollY) window.scroll(window.scrollX, top);
if (thumb.nextSibling.offsetHeight > d.body.clientHeight && (top = a.getBoundingClientRect().top) < 0) {
window.scroll(window.scrollX, window.scrollY + top);
}
return imgExpand.contract(thumb);
} else {

View File

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