From 3d1de50d152f6604cdb6a80032298804e4003efd Mon Sep 17 00:00:00 2001 From: ahodesuka Date: Wed, 18 Jan 2012 21:00:54 -0600 Subject: [PATCH] Scroll to the same position on the thumbnail as was being viewed before contracting --- script.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script.coffee b/script.coffee index d4c4aabae..b21c55485 100644 --- a/script.coffee +++ b/script.coffee @@ -2316,8 +2316,9 @@ imgExpand = toggle: (a) -> thumb = a.firstChild if thumb.hidden - if thumb.nextSibling.offsetHeight > d.body.clientHeight and (top = a.getBoundingClientRect().top) < 0 - window.scroll window.scrollX, window.scrollY + top + rect = a.getBoundingClientRect() + d.body.scrollTop += if rect.top < 0 then rect.top + thumb.height / (rect.height / rect.top * -1) else 0 + d.body.scrollLeft += if rect.left < 0 then rect.left + thumb.width / (rect.width / rect.left * -1) else 0 imgExpand.contract thumb else imgExpand.expand thumb