miromannino / Justified-Gallery

Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.
http://miromannino.github.io/Justified-Gallery/
MIT License
1.68k stars 298 forks source link

JG blocks scrollTop()? #350

Closed jefftucker1952 closed 3 years ago

jefftucker1952 commented 3 years ago

I've put a little script on some pages so that, if the visitor leaves the page, then returns, his original scroll position is retained:

function retainPos() {
    var pathName = document.location.pathname;
    window.onbeforeunload = function () {
        var scrollPosition = $(document).scrollTop();
        sessionStorage.setItem("scrollPosition_" + pathName, scrollPosition.toString());
    }
    if (sessionStorage["scrollPosition_" + pathName]) {
        $(document).scrollTop(sessionStorage.getItem("scrollPosition_" + pathName));
    }
};
$(document).ready(retainPos);

Works just fine on a simple page of thumbnails. But if I use Justified-Gallery, it no longer works. I can't figure out what JG is doing that interferes with this simple mechanism.

Can anyone suggest where I should be looking?

jefftucker1952 commented 3 years ago

Never mind. I need to get a callback from jg.complete, so this is just a code engineering problem.