brutaldesign / swipebox

A touchable jQuery lightbox
1.96k stars 667 forks source link

Close swipebox on back button / go back in history #291

Open georg90 opened 8 years ago

georg90 commented 8 years ago

Probably I overlooked something. But it seems this isn't a feature, yet? It would be nice to have the possibility to close the swipebox on going back in history (back button on phone, go back in browser)

The same way http://photoswipe.com implemented it:

PhotoSwipe manipulates the browser’s history so that the user can link to each gallery item and close the gallery via the “back” button. The initial URL is restored when the gallery is closed.

https://github.com/browserstate/history.js/

hpcraink commented 7 years ago

Messing with the history / documentat location is not advisable in light of other JS libraries working with history. Nevertheless the CloseOnBack branch in https://github.com/hpcraink/swipebox/tree/CloseOnBack implements an option (false by default to mimick previous behaviour) to close the SwipeBox, but rewrite the window location to the previous location.