|
96 | 96 | bgClickAction: 'close', |
97 | 97 | bgOpacity: 0.8, |
98 | 98 | padding: { top: 20, bottom: 20, left: 20, right: 20 }, |
| 99 | + showHideAnimationType: 'zoom', |
| 100 | + showAnimationDuration: 300, |
| 101 | + hideAnimationDuration: 300, |
99 | 102 | }); |
100 | 103 |
|
101 | | - // Parse data from image tags |
102 | | - lightbox.on('uiRegister', function () { |
103 | | - const pswp = lightbox.pswp; |
| 104 | + // Smooth border-radius transition: remove during animation, restore after |
| 105 | + let currentThumb: HTMLElement | null = null; |
104 | 106 |
|
105 | | - // Add class after zoom animation to handle border radius |
106 | | - // We check if pswp exists (it should inside uiRegister, but safe-check doesn't hurt) |
107 | | - if (pswp) { |
108 | | - } |
| 107 | + lightbox.on('openingAnimationStart', () => { |
| 108 | + currentThumb = lightbox.pswp?.currSlide?.data?.element as HTMLElement; |
| 109 | + currentThumb?.classList.add('pswp-animating'); |
| 110 | + }); |
| 111 | + |
| 112 | + lightbox.on('openingAnimationEnd', () => { |
| 113 | + document.querySelector('.pswp')?.classList.add('pswp--anim-complete'); |
| 114 | + }); |
109 | 115 |
|
| 116 | + lightbox.on('closingAnimationStart', () => { |
| 117 | + document.querySelector('.pswp')?.classList.remove('pswp--anim-complete'); |
| 118 | + }); |
| 119 | + |
| 120 | + lightbox.on('closingAnimationEnd', () => { |
| 121 | + currentThumb?.classList.remove('pswp-animating'); |
| 122 | + currentThumb = null; |
| 123 | + }); |
| 124 | + |
| 125 | + // Parse data from image tags |
| 126 | + lightbox.on('uiRegister', function () { |
110 | 127 | lightbox.pswp.ui.registerElement({ |
111 | 128 | name: 'custom-caption', |
112 | 129 | order: 9, |
|
0 commit comments