fix(photoswipe): target currSlide.container not currSlide.el

pswp.currSlide is a Slide instance whose DOM element is stored as
.container (.pswp__zoom-wrap). The .el property belongs to the
itemHolder wrapper, not the Slide — so currSlide.el was always
undefined, the null-guard exited early, and no animation played.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr
This commit is contained in:
2026-06-21 21:45:22 +02:00
parent 9f503c011d
commit 53bfe5955d
3 changed files with 4 additions and 4 deletions
@@ -124,7 +124,7 @@ lightbox.on('afterOpen', function () {
if (!keyDir) return; if (!keyDir) return;
var dir = keyDir; var dir = keyDir;
keyDir = 0; keyDir = 0;
var el = pswp.currSlide && pswp.currSlide.el; var el = pswp.currSlide && pswp.currSlide.container;
if (!el) return; if (!el) return;
el.classList.remove('pswp-key-from-left', 'pswp-key-from-right'); el.classList.remove('pswp-key-from-left', 'pswp-key-from-right');
el.offsetWidth; el.offsetWidth;
+1 -1
View File
@@ -159,7 +159,7 @@ lightbox.on('afterOpen', function () {
if (!keyDir) return; if (!keyDir) return;
var dir = keyDir; var dir = keyDir;
keyDir = 0; keyDir = 0;
var el = pswp.currSlide && pswp.currSlide.el; var el = pswp.currSlide && pswp.currSlide.container;
if (!el) return; if (!el) return;
el.classList.remove('pswp-key-from-left', 'pswp-key-from-right'); el.classList.remove('pswp-key-from-left', 'pswp-key-from-right');
el.offsetWidth; el.offsetWidth;
+2 -2
View File
@@ -528,10 +528,10 @@ lightbox.on('afterOpen', function () {
if (!keyDir) return; if (!keyDir) return;
var dir = keyDir; var dir = keyDir;
keyDir = 0; keyDir = 0;
var el = pswp.currSlide && pswp.currSlide.el; var el = pswp.currSlide && pswp.currSlide.container;
if (!el) return; if (!el) return;
el.classList.remove('pswp-key-from-left', 'pswp-key-from-right'); el.classList.remove('pswp-key-from-left', 'pswp-key-from-right');
el.offsetWidth; // restart animation if navigating rapidly el.offsetWidth;
el.classList.add(dir > 0 ? 'pswp-key-from-right' : 'pswp-key-from-left'); el.classList.add(dir > 0 ? 'pswp-key-from-right' : 'pswp-key-from-left');
clearTimeout(clearTimer); clearTimeout(clearTimer);
clearTimer = setTimeout(function () { el.classList.remove('pswp-key-from-left', 'pswp-key-from-right'); }, 400); clearTimer = setTimeout(function () { el.classList.remove('pswp-key-from-left', 'pswp-key-from-right'); }, 400);