A dynamic caption plugin for PhotoSwipe v5. Automatically positions the caption aside or below the image.
A dynamic caption plugin for PhotoSwipe v5. Automatically positions the caption aside or below the image.
**[> Plugin demo { return slide.data.element.querySelector('img').getAttribute('alt'); }
#### `type: 'auto'`
Position type of the caption can be 'auto', 'below', or 'aside'.
- 'below' - caption will always be placed below the image
- 'aside' - caption will always be placed on the right side of the image
- 'auto' - the plugin will try to automatically determine the best position (depending on available space)
#### `mobileLayoutBreakpoint: 600`
Maximum window width at which mobile layout should be used, or a function that should return true if mobile layout should be used. For example:
```js
mobileLayoutBreakpoint: (pswp, captionPlugin) => {
return (window.innerWidth < 750);
}
…
css
.pswp__dynamic-caption--aside {
max-width: 300px;
padding: 20px 15px 20px 20px;
margin-top: 70px;
}
.pswp__dynamic-caption--below {
max-width: 700px;
padding: 15px 0 0;
}
.pswp__dynamic-caption--mobile {
background: rgba(0, 0, 0, 0.5);
padding: 10px 15px;
}pswp__dynamic-caption--below class, so the size can also be adjusted via CSS.pswp__dynamic-caption--aside class, so the size can be adjusted via CSS.If mobileLayoutBreakpoint requirements are met:
mobileCaptionOverlapRatio) - just overlap the caption and keep the image at the default position.dynamicCaption property of a slide. For example pswp.currSlide.dynamicCaption.paddingFn (introduced in 5.1.61)pswp__dynamic-caption--on-hor-edge when it's on horizontal edge (x position is less than threshold). Added option horizontalEdgeThreshold to control this.mobileCaptionOverlapRatio to control this.No open issues yet, or sync has not completed.