New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lightgallery does not work on click #863
Comments
Any one there ??? :( |
@bridgemove same issue here! I tried the solution given by others users:
and it opens the lightbox, but in less than a second it's close and the next error appears in the console:
|
I solve this issue, adding a condition to verifier if document is fullscreen mode Fullscreen.prototype.exitFullscreen = function() {
if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}; |
Then can you let me know what will be full code now ? Really thanks for that please. |
Because I don't know how to use this code of yours ? As I already provided my code above so let me know how can I use yours with mine to make it working properly. Thanks for your entire help and time in advance. |
Write this code into file Fullscreen.prototype.exitFullscreen = function() {
if (isFullScreen()) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}; |
The function function isFullScreen() {
return (
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
document.msFullscreenElement
);
} |
Thank you very much for your quick response buddy. I will surely try it out and will let you know with any of the result. Thanks once again ;) |
So, the code you provided earlier I will replace that with line 82 with same code. Right ? |
Yes! diff --git a/modules/lg-fullscreen.js b/modules/lg-fullscreen.js
index 712b943..6d47eff 100644
--- a/modules/lg-fullscreen.js
+++ b/modules/lg-fullscreen.js
@@ -80,14 +80,16 @@
};
Fullscreen.prototype.exitFullscreen = function() {
- if (document.exitFullscreen) {
- document.exitFullscreen();
- } else if (document.msExitFullscreen) {
- document.msExitFullscreen();
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
- } else if (document.webkitExitFullscreen) {
- document.webkitExitFullscreen();
+ if (isFullScreen()) {
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ } else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ } else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ } else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ }
}
}; |
If you use just the file Fullscreen.prototype.exitFullscreen = function() {
if (isFullScreen()) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}; |
Surely I will tey it by tomorrow and will update you with its behavior. |
@douglasresende tks for your help. Unfortunately it didn't solved my problem... I mean, the console error that said "Uncaught (in promise) TypeError: Document not active" it's solved actually! But my original problem that "it opens the lightbox, but in less than a second it's close" still the same. If I open the lightbox in a traditional way (just click on the image) it works just fine. Any other idea? Tks you in advance! |
I'm sorry! My code solve other issue (the same error, but trying close the gallery) |
Yes of course and tks you again! I create an example of the error in this link: https://www.fryla.com.ar/cliOcampo/testForGithub with this code:
|
Note that if you click any of the photos, it's working fine. But when you click the button ("Ver fotos") ... the one second open/close ocurrs =S |
It's simple to solve. Just call the method $('#btnVerFotos').on('click', function(event) {
event.preventDefault();
$('#first-item').trigger('click');
}); |
Can't believe myself (face palm by 10), so obvious... I forgot the Ockham Razor principle!! |
This issue has been automatically marked as stale because it has not had recent activity. If the issue is still valid for version 2.x, please re-open. Apologize for not responding on time. Thank you for your contributions. |
I want to run lightgallery on click, there is a solid reason so I want to run lightgallery on click function. The issue is that it works on second click not on first click. That's weired. I want it to work on first click always and on close it should close gallery. And on new click it should start new gallery lightbox. This is the code and it works as intended **but only issue is that it works on second click not on first click.
**
`
`
Any one there who can help me out what's wrong I am doing ??? Really wasted my time in this but it should be quiet simple but its not that easy for me at least ...
In short I want above my function to run on click each time but it runs on second click don't know why ? My light gallery starts only on second click ... any solutions please ???
Thanks
The text was updated successfully, but these errors were encountered: