Make sure that .pswp element markup is correct (step 2 in the documentation). And make sure that <script> that initializes PhotoSwipe is after .pswp element (or run it in document.ready).
Please provide a reduced test case (isolated example) that reproduces the problem (upload example to your server, or attach .zip'ed project, or use codepen/jsfiddle).
Hi,
I think it was the fact that I had a non-figure element in the collection. A quick check on the nodeName and all is well.
@craigmdennis Currently having the same issue when trying to open Photoswipe through parsing the URL hash. Mind sharing your workaround?
@rppld I can't remember the specifics but — based on my previous comment — where Photoswipe loops through the elements, I skipped to the next element when it wasn't a <figure>.
for(var i = 0; i < numNodes; i++) {
figureEl = thumbElements[i]; // <figure> element
// include only element nodes that are `<figure>`s
if(figureEl.nodeType !== 1 || figureEl.nodeName !== 'FIGURE') {
continue;
}
// ...
}
The above is around line 19
I got the same problem. I moved the scripts before the end of </body> tag and solved it. Everything works fine.
photoswipe.min.js:4 Uncaught TypeError: Cannot read property 'firstChild' of undefined
I have same error, please help
@fkamlesh The solution is if you are referring codePen example then, do not forget to add the HTML that's defined from line# 69 to 133 (i.e. EOF)
Most helpful comment
Moving initiating
All 11 comments
Make sure that
.pswpelement markup is correct (step 2 in the documentation). And make sure that<script>that initializes PhotoSwipe is after.pswpelement (or run it in document.ready).Please provide a reduced test case (isolated example) that reproduces the problem (upload example to your server, or attach .zip'ed project, or use codepen/jsfiddle).
Hi,
I think it was the fact that I had a non-figure element in the collection. A quick check on the nodeName and all is well.
@craigmdennis Currently having the same issue when trying to open Photoswipe through parsing the URL hash. Mind sharing your workaround?
@rppld I can't remember the specifics but — based on my previous comment — where Photoswipe loops through the elements, I skipped to the next element when it wasn't a
<figure>.The above is around
line 19I got the same problem. I moved the scripts before the end of
</body>tag and solved it. Everything works fine.photoswipe.min.js:4 Uncaught TypeError: Cannot read property 'firstChild' of undefined
I have same error, please help
@fkamlesh The solution is if you are referring codePen example then, do not forget to add the HTML that's defined from line# 69 to 133 (i.e. EOF)
Moving initiating