nanostudio-org / nano_photos_provider2

PHP photos provider for nanogallery2
https://nanophotosprovider2.nanostudio.org/
48 stars 12 forks source link

With pagination enabled, it always back to page 1 when closing an album #22

Open marhensa opened 5 years ago

marhensa commented 5 years ago

Hi, first of all, thank you for this amazing work. It's really great! I'm here just like to give a some suggestion.

From user standpoint it's frustating when we open an album, browsing it and then close it, it always back to page one (pagination enabled). Maybe it should be better if it remembers which page the last album located in pagination mode.

bhartvigsen commented 5 years ago

I did a similar thing to allow the user to return to their original page after clearing search. Perhaps you can use this method to do what you want. At the top of the script I added:

var nanogalleryCurrentPage; var G;

And then in ManagePagination() add a line to store the current page (nanoGalleryCurrentPage):

    var elt$ = jQuery('<div id="galleryPage-' + i + '" class="' + c + '">' + p + '</div>').appendTo(G.$E.conTnBottom);
    elt$.data('pageNumber', i );
    elt$.click( function(e) {
      nanogalleryCurrentPage = jQuery(this).data('pageNumber');
      G.GOM.pagination.currentPage = jQuery(this).data('pageNumber');
      TriggerCustomEvent('pageChanged');
      GalleryDisplayPart1( true );
      GalleryDisplayPart2( true );
    });

G.GOM.pagination.currentPage = ; will allow you to set the page.

You'll have to do a little dev work, this isn't a complete guide it's just what I (kinda) remember from implementing a similar thing. The key thing is storing the user's page in the ManagePagination() method.