diff --git a/assets/ps5/frontend.js b/assets/ps5/frontend.js index 0527e4c..ec58815 100644 --- a/assets/ps5/frontend.js +++ b/assets/ps5/frontend.js @@ -347,9 +347,9 @@ let lbwpsInit = function(domUpdate) { options.history = lbwpsOptions.history === '1'; options.zoomEl = lbwpsOptions.show_zoom === '1'; options.tapToToggleControls = lbwpsOptions.taptotoggle === '1'; - options.desktopSlider = lbwpsOptions.desktop_slider === '1'; */ + const lightbox = new PhotoSwipeLightbox(options); lightbox.on('destroy', () => { const pswpElements = document.getElementsByClassName('pswp__scroll-wrap'); @@ -405,6 +405,25 @@ let lbwpsInit = function(domUpdate) { ); } + // Add sliding in desktop mode + options.desktopSlider = lbwpsOptions.desktop_slider === '1'; + + if (options.desktopSlider) { + const lbwpsGoTo = (index, animate = false) => { + const pwsp = lightbox.pswp; + index = pwsp.getLoopedIndex(index); + const indexChanged = pwsp.mainScroll.moveIndexBy(index - pwsp.potentialIndex, animate); + + if (indexChanged) { + pwsp.dispatch('afterGoto'); + } + } + lightbox.on('uiRegister', () => { + lightbox.pswp.next = () => lbwpsGoTo(lightbox.pswp.potentialIndex + 1, true); + lightbox.pswp.prev = () => lbwpsGoTo(lightbox.pswp.potentialIndex - 1, true); + }); + } + lightbox.init(); if (lbwpsOptions.hide_scrollbars === '1') { hideScrollbar(); diff --git a/assets/ps5/frontend.min.js b/assets/ps5/frontend.min.js index b56b437..588ee06 100644 --- a/assets/ps5/frontend.min.js +++ b/assets/ps5/frontend.min.js @@ -35,6 +35,8 @@ if(lbwpsOptions.show_caption==='1'){const captionPlugin=new PhotoSwipeDynamicCap if(slide.data.exif&&slide.data.exif!==''){caption=caption+'
'+slide.data.exif+'
'} return caption},mobileLayoutBreakpoint:function(){if(this.options.type!=='overlay'){return window.innerWidth<600}}})} if(lbwpsOptions.idletime>0){const autoHideUI=new PhotoSwipeAutoHideUI(lightbox,{idleTime:lbwpsOptions.idletime})} +options.desktopSlider=lbwpsOptions.desktop_slider==='1';if(options.desktopSlider){const lbwpsGoTo=(index,animate=!1)=>{const pwsp=lightbox.pswp;index=pwsp.getLoopedIndex(index);const indexChanged=pwsp.mainScroll.moveIndexBy(index-pwsp.potentialIndex,animate);if(indexChanged){pwsp.dispatch('afterGoto')}} +lightbox.on('uiRegister',()=>{lightbox.pswp.next=()=>lbwpsGoTo(lightbox.pswp.potentialIndex+1,!0);lightbox.pswp.prev=()=>lbwpsGoTo(lightbox.pswp.potentialIndex-1,!0)})} lightbox.init();if(lbwpsOptions.hide_scrollbars==='1'){hideScrollbar()} lightbox.loadAndOpen(index)};window.lbwpsCopyToClipboard=function(str){const el=document.createElement('textarea');el.value=str;el.setAttribute('readonly','');el.style.position='absolute';el.style.left='-9999px';document.body.appendChild(el);const selected=document.getSelection().rangeCount>0?document.getSelection().getRangeAt(0):!1;el.select();document.execCommand('copy');document.body.removeChild(el);if(selected){document.getSelection().removeAllRanges();document.getSelection().addRange(selected)}} let hashData=photoswipeParseHash();if(hashData.pid&&hashData.gid){let elements;if(hashData.gid==1){elements=document.querySelectorAll('a[data-lbwps-width]:not([data-lbwps-gid])')}else{elements=document.querySelectorAll('a[data-lbwps-width][data-lbwps-gid="'+hashData.gid+'"]')} diff --git a/lightbox-photoswipe.php b/lightbox-photoswipe.php index 2f3dc37..d2922e1 100644 --- a/lightbox-photoswipe.php +++ b/lightbox-photoswipe.php @@ -3,7 +3,7 @@ Plugin Name: Lightbox with PhotoSwipe Plugin URI: https://wordpress.org/plugins/lightbox-photoswipe/ Description: Lightbox with PhotoSwipe -Version: 5.0.44 +Version: 5.1.0 Author: Arno Welzel Author URI: http://arnowelzel.de Text Domain: lightbox-photoswipe diff --git a/readme.txt b/readme.txt index 4bacdbc..43efeb8 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: awelzel Tags: attachments, images, gallery, lightbox, fancybox, photoswipe Requires at least: 5.3 Tested up to: 6.3 -Stable tag: 5.0.44 +Stable tag: 5.1.0 Donate link: https://paypal.me/ArnoWelzel License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -219,6 +219,13 @@ If you change any of the stylesheets or frontend scripts in `src/js` or `src/lib == Changelog == += 5.1.0 = + +PhotoSwipe 5 integration: + +* Updated PhtooSwipe to version 5.4.2. +* Added desktop sliding similar to PhotoSwipe 4. + = 5.0.44 = * Fixed a compatibility issue with WPML. Images should now also be recognized as "local" when they are used on a translated version of the website. diff --git a/src/LightboxPhotoSwipe/LightboxPhotoSwipe.php b/src/LightboxPhotoSwipe/LightboxPhotoSwipe.php index 0d46ffe..8ce0e45 100644 --- a/src/LightboxPhotoSwipe/LightboxPhotoSwipe.php +++ b/src/LightboxPhotoSwipe/LightboxPhotoSwipe.php @@ -11,7 +11,7 @@ */ class LightboxPhotoSwipe { - const VERSION = '5.0.44'; + const VERSION = '5.1.0'; const SLUG = 'lightbox-photoswipe'; const META_VERSION = '12'; const CACHE_EXPIRE_IMG_DETAILS = 86400; diff --git a/templates/options-tab5.inc.php b/templates/options-tab5.inc.php index cf13f96..dce2a87 100644 --- a/templates/options-tab5.inc.php +++ b/templates/options-tab5.inc.php @@ -1,12 +1,12 @@