How do I control the pswp__counter so, let's assume, I modify it that after each 5th a slide of non-image content shows up and it shouldn't be counted as an image.
I've tried if (i % 5 == 0 && i !== 0) { //insert customEl html }, but I don't know how to control pswp's counter in the top left corner. Any help with this? Much appreciated!
If you don't want to modify the UI directly, you can override its updateIndexIndicator UI function.
...
var pswp = new PhotoSwipe( ... );
pswp.init();
// select counter element (in any way you wish)
var indexIndicatorDOMElement = document.querySelectorAll('.pswp__counter')[0];
// override updateIndexIndicator function
pswp.ui.updateIndexIndicator = function() {
indexIndicatorDOMElement.innerHTML = (pswp.getCurrentIndex()+1) +
pswp.options.indexIndicatorSep +
pswp.options.getNumItemsFn();
};
// force index update
pswp.ui.updateIndexIndicator();
Most helpful comment
If you don't want to modify the UI directly, you can override its
updateIndexIndicatorUI function.