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

photoswipe.min.js:4 -- Uncaught TypeError: Cannot read property 'firstChild' of undefined(…) #1255

Open ZAJDAN opened 7 years ago

ZAJDAN commented 7 years ago

Hello, right now I am trying use the Photoswipe, but I am facing a problem: Uncaught TypeError: Cannot read property 'firstChild' of undefined(…) ...photoswipe.min.js:4

getChildByClass @ photoswipe.min.js:4 init @ photoswipe.min.js:4 openPhotoSwipe @ private.js:30 (anonymous function) @ private.js:33

Thanks for any hint

svdg commented 7 years ago

I have this problem too, help is very appreciated.

svdg commented 7 years ago

This Codepen got me going: https://codepen.io/dimsemenov/pen/ZYbPJM. Very nice photo swiper, awesome piece of work!

ZAJDAN commented 7 years ago

so You want to say, that this code works on your website?

svdg commented 7 years ago

Yes. Still one question: is there an example with options? I want to hide download and translate option text.

Op 21 dec. 2016, om 08:44 heeft Zdenek notifications@github.com het volgende geschreven:

so You want to say, that this code works on your website?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dimsemenov/PhotoSwipe/issues/1255#issuecomment-268457559, or mute the thread https://github.com/notifications/unsubscribe-auth/AEXdJvr8L8zwQKxCNwDCZGfG4lgh-S5Hks5rKNjigaJpZM4LRuJS.

fabricionaweb commented 7 years ago

Your first instance argument (pswpElement) need to be DOM Element, like a document.querySelector or jquery $('selector')[0]

fatih905 commented 6 years ago

Add html

<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="pswp__bg"></div>
    <div class="pswp__scroll-wrap">
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close"></button>
                <button class="pswp__button pswp__button--share"></button>
                <button class="pswp__button pswp__button--fs"></button>
                <button class="pswp__button pswp__button--zoom"></button>
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>
            <button class="pswp__button pswp__button--arrow--left"></button>
            <button class="pswp__button pswp__button--arrow--right"></button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>