// registerElement method must be called within or after uiRegister eventpswp.ui.registerElement({// Unique name of the UI element,name:'test123',// Classname of the element. // Optional, if not defined - name will be used // in format pswp__button--name, or pswp__nameclassName:undefined,// Order of element, default order elements:// counter - 5, zoom button - 10, info - 15, close - 20.order:9,// If element should be // rendered as buttonisButton:true,// Element tag name,// Optional, if not defined - button or div will be usedtagName:'a',// Button title, optionaltitle:'Button title',// Button aria-label attribute,// if not defined - title will be usedariaLabel:undefined,// html string, will be added inside button, optional// can also be an object with svg datahtml:'Test',// Element container, possible values:// - 'bar' (top toolbar, .pswp__top-bar, default value), // - 'wrapper' (scroll viewport wrapper, .pswp__scroll-wrap),// - 'root' (root element of the dialog, .pswp) // If you add a text inside 'wrapper' - it won't be selectable,// as PhotoSwipe intersects all touch events there.appendTo:'bar',// callback is triggered right before // corresponding element is added to DOM// (while dialog is opening/creating)onInit:function(el,pswp){// el - reference to your DOM element// pswp - PhotoSwipe object// You may modify element here, for example:el.classList.add('my-test-class');},// when user clicks or taps on elementonClick:function(event,el,pswp){console.log('clicked element:',el);}});
All default buttons and elements also use this syntax, so you can look up more examples in folder /src/js/ui/ within the repository.
If you need to override or slightly adjust existing buttons - feel free to use uiElement filter.
registerElement is not the only method to add various UI elements, it’s just an optional shortcut. Feel free to append elements manually.