dimsemenov / PhotoSwipe

JavaScript image gallery for mobile and desktop, modular, framework independent
http://photoswipe.com
MIT License
24.18k stars 3.31k forks source link

Cannot initialize PhotoSwipe #1388

Open balazsorban44 opened 7 years ago

balazsorban44 commented 7 years ago

I am trying to initialize my gallery, but it throws these errors:

Uncaught TypeError: Cannot set property 'PhotoSwipeUI_Default' of undefined Uncaught TypeError: Cannot set property 'PhotoSwipe' of undefined Uncaught ReferenceError: PhotoSwipe is not defined

I imported the scripts like this:

`

` And here is my init code for the gallery. ``` const pwspElement = document.querySelector('.pswp'), items = [/Items here/], options = {index: 0}, gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options) gallery.init() ``` According to the Chrome console, the problem is on this line in photoswipe.js: `root.PhotoSwipe = factory();` UPDATE: Linking the the 2 JS scripts with script tag in HTML as below works, but when I want to concatenate the files with my JS with Gulp, I get the above error. ``` Githubissues.
  • Githubissues is a development platform for aggregating issues.