UNPKG

photoswipe

Version:
53 lines (49 loc) 1.22 kB
/* Backward and forward arrow buttons */ function initArrowButton(element, pswp, isNextButton) { element.classList.add('pswp__button--arrow'); pswp.on('change', () => { if (!pswp.options.loop) { if (isNextButton) { element.disabled = !(pswp.currIndex < pswp.getNumItems() - 1); } else { element.disabled = !(pswp.currIndex > 0); } } }); } export const arrowPrev = { name: 'arrowPrev', className: 'pswp__button--arrow--prev', title: 'Previous', order: 10, isButton: true, appendTo: 'wrapper', html: { isCustomSVG: true, size: 60, inner: '<path d="M29 43l-3 3-16-16 16-16 3 3-13 13 13 13z" id="pswp__icn-arrow"/>', outlineID: 'pswp__icn-arrow' }, onClick: 'prev', onInit: initArrowButton }; export const arrowNext = { name: 'arrowNext', className: 'pswp__button--arrow--next', title: 'Next', order: 11, isButton: true, appendTo: 'wrapper', html: { isCustomSVG: true, size: 60, inner: '<use xlink:href="#pswp__icn-arrow"/>', outlineID: 'pswp__icn-arrow' }, onClick: 'next', onInit: (el, pswp) => { initArrowButton(el, pswp, true); } };