Fix img_centerline by not relying on offsetparent.

This commit is contained in:
voussoir 2023-06-04 14:17:51 -07:00
parent 7bacc72463
commit 2e75553284

View file

@ -263,7 +263,7 @@ def write_directory_index(directory):
}
function scroll_to_img(img)
{
const img_centerline = img.offsetParent.offsetTop + img.offsetTop + (img.offsetHeight / 2);
const img_centerline = img.getBoundingClientRect().top + img.ownerDocument.defaultView.pageYOffset + (img.offsetHeight / 2);
// document.body.scrollTop = img_centerline - (window.innerHeight / 2);
desired_scroll_position = Math.round(img_centerline - (window.innerHeight / 2));
scroll_step();