Lightgallery: [v2, hash] navigate to different slides via browser back/forward buttons not working

Created on 21 May 2021  路  6Comments  路  Source: sachinchoolur/lightGallery

Description

Navigate to different slides via browser back/forward buttons not working
When the lgHash plugin is enabled, changing slides creates new hashes, but pressing the back/forward buttons does not change the slides or closes the gallery, but completely reloads the page

Steps to reproduce

  1. Enable hash plugin
  2. Open gallery
  3. Click forward 3 times
  4. Click browser back button

Demo:
https://www.lightgalleryjs.com/demos/hash/

Expected result

You should see the previous slide, not close the gallery. On the other hand, when you pressed back on the first slide, the gallery should close but the page should not reload

Actual result

Page is reload

Additional context

Love your work and version 2 ;)

Feature Request

Most helpful comment

I'll try to add a new option in the hash plugin as @miedzikd suggested.

All 6 comments

The primary role of the hash plugin is to provide an option to share slides via URL. We already have multiple options for navigating between slides and closing the gallery. If you really want to navigate slides via the browser back button, for now, you can fork the repo and replace the replaceState with pushState.

Let me know what you think

Thanks @sachinchoolur for the explanations and tips :)

I don't think it's important for desktops ... but for mobile devices ... opening the gallery looks like going to a new page. Sometimes it is easier than looking for the X (which disappears after a few seconds) it is easier to make "undo gesture" or click the "undo arrow". Then, however, the user lands in a completely different place. Especially if he just came from Google to the SPA website ... In this case you will return to the search results.

Please consider this one more time... Mabe you can add a new option for hash plugin?

Best Regards :)
Daniel

I think this is very important especially for mobile and SPAs like @miedzikd said, but I'm sure there are many use cases where this would be useful.

I'll try to add a new option in the hash plugin as @miedzikd suggested.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

any news @sachinchoolur ?

Was this page helpful?
0 / 5 - 0 ratings