Skip to content
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

Wait for DOMContentLoaded event instead of checking for document.body #88

Closed
wants to merge 1 commit into from

Conversation

djmaze
Copy link

@djmaze djmaze commented Aug 23, 2021

document.body might not yet be available during the load of the script (especially with the UMD version). So have to wait for it to become available.

Fixes #81

@shamarin
Copy link

Tested with those changes, it's working now.

@shamarin
Copy link

But another problem now execute if body tag contains many elements, not only fancybox. Clicks on any element in body throw an error
Uncaught DOMException: Element.matches: '[object Map Iterator]' is not a valid selector fancybox.umd-ecf728b6.js:1
And also fancybox modal doesn't work in that situation.

@fancyapps
Copy link
Owner

Hi,

I added event listener to document instead of the document.body and it should work now. Please, let me know if other issues arise.

@fancyapps fancyapps closed this Aug 25, 2021
@shamarin
Copy link

Hi,

I added event listener to document instead of the document.body and it should work now. Please, let me know if other issues arise.

Ok, thank you. Will check it tomorrow.

@djmaze djmaze deleted the fix-umd-usage branch August 25, 2021 14:00
@shamarin
Copy link

Hi,

I added event listener to document instead of the document.body and it should work now. Please, let me know if other issues arise.

Tested, without any other scripts on page it's working, but on real project it's not where there are many other scripts and JS libs.
The same error in console

Uncaught DOMException: Element.matches: '[object Map Iterator]' is not a valid selector 

Seams that there is a conflict with other libs.

@fancyapps
Copy link
Owner

@shamarin Since I am not able to reproduce this issue, could you, please, share your page/demo so I could take a look? If you do not want to show your page publicly, you can contact privately, contact information is on the homepage.

@fancyapps
Copy link
Owner

@shamarin Could you please try the latest version and see if it works better?

@shamarin
Copy link

@shamarin Could you please try the latest version and see if it works better?

Will try it today.

@shamarin
Copy link

Tested, the same error.

@shamarin
Copy link

shamarin commented Sep 4, 2021

With stable version there is no error now, but declarative method not working.

@fancyapps
Copy link
Owner

fancyapps commented Sep 4, 2021

Sorry, but since I can not reproduce that issue and you did not provide a live demo, I will not be able to make it work for you.

@djmaze
Copy link
Author

djmaze commented Sep 6, 2021

Works for me now. Thanks @fancyapps !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fancybox is not working if to include main script load via head tag
3 participants