Working with Photoswipe in meteor init() function not working properly
See original GitHub issueI keep getting an error that states “spectrum_photoswipe.js:63 Uncaught TypeError: Cannot read property ‘className’ of undefined” It’s refrencing this block of code:
removeClass: function(el, className) { var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
el.className = el.className.replace(reg, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }
My code is passing items and options correctly like so:
var listingId = template.data.listingId,
imgs = ListingCollection.findOne({_id: listingId}).images;
var items = [];
for(var i =0; i < imgs.length; i++) {
var tempImg = new Image();
tempImg.src = imgs[i];
var itemObject = {"src": "", "w": "", "h": ""};
itemObject.src = imgs[i];
itemObject.w = tempImg.width;
itemObject.h = tempImg.height;
items[i] = itemObject;
}
var options = {
index: 0,
history: false,
focus: false,
showAnimationDuration: 0,
hideAnimationDuration: 0
};
var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
And I’ve checked to make sure that the pswp element is in the DOM. I’m not really sure what’s going on here. Any help would be greatly appreciated
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Getting Started - PhotoSwipe
PhotoSwipe requires predefined image dimensions, you must define the width and height of each image. PhotoSwipe is not designed to display very large...
Read more >Very low meteor performance in production
I see that your site has large images that can slow down, on the other hand does not use the rendering server, however...
Read more >How to allow the user to click on a link while ... - Stack Overflow
EDIT: This is how I initialize the photoswipe gallery. function showSoftwareGallery(sections, index){ var pswpElement = document.
Read more >Dogfalo/materialize - Gitter
The material_select() call is being executed I guess because of the added HTML to the ... its working and more issues are appearing,...
Read more >Rocket.Chat - HISTORY.md - OW2 Gitlab
Creation of Omnichannel rooms not working correctly through the Apps ... the Template events() call, once in the reactions init.js and the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, I’m not the plugin author 😃 Btw. in #1128 someone already mentioned issues with
--
in comment. Glad you got it working!Thank you! That was the issue, one of the commented out sections in the pswp uses – in the comment:
<!-- element will get class pswp__preloader--active when preloader is running -->
and that commented out the pswp__preloader class. You might want to consider changing that comment in the documentation. Thanks for the help!