Answer the question
In order to leave comments, you need to log in
How to close the photo gallery with the back button on a smartphone?
The essence of the question: how to implement the closing of the photo gallery when the smartphone's back button is pressed? I use a LightGallery gallery on jQuery - I would like that after viewing the photo I could press the back button and the gallery was closed - and now it returns to the previous page ... Perhaps someone can point me in the right direction to solve the problem.
<div class="gym_gallery">
<ul id="lightgallery" id="hash" class="gallery">
<li data-src="../img//gym/original_img/01.JPG" data-sub-html="Фитнес клуб">
<a href="#">
<img src="../img/gym/small_img/01.JPG ">
</a>
</li>
</div>
jQuery(document) .ready(function ($){
$("#lightgallery") .lightGallery({
});
$("#lightgallery01") .lightGallery({
});
$('#hash').lightGallery();
});
Answer the question
In order to leave comments, you need to log in
First you need to learn how to catch the "Back" button click. Here is the first link from Stackoverflow - there is a lot of stuff written there. Click
Next, maybe consider using event.preventDefault() to prevent returning to the previous page.
Also, most likely, it is worth keeping track of the current state of the gallery, so as not to prevent the user from returning to the previous page when the gallery is closed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question