PageSourceSearch

https://www.ltz.se/assets/rev/js/photoswipe-dynamic-caption-plugin.esm-5CMK5AKF.js

js ltz.se collected 2026-10-02 07:18:42 UTC 6,705 bytes, 2 lines download raw bytes

1import"./chunk-6KHOHYTW.js";var y={captionContent:".pswp-caption-content",type:"auto",horizontalEdgeThreshold:20,mobileCaptionOverlapRatio:.3,mobileLayoutBreakpoint:600,verticallyCenterImage:!1},s=class{constructor(t,e){this.options={...y,...e},this.lightbox=t,this.lightbox.on("init",()=>{this.pswp=this.lightbox.pswp,this.initCaption()})}initCaption(){let{pswp:t}=this;t.on("change",()=>{this.showCaption(this.pswp.currSlide)}),t.on("calcSlideSize",e=>this.onCalcSlideSize(e)),t.on("slideDestroy",e=>{e.slide.dynamicCaption&&(e.slide.dynamicCaption.element&&e.slide.dynamicCaption.element.remove(),delete e.slide.dynamicCaption)}),t.on("zoomPanUpdate",({slide:e})=>{if(t.opener.isOpen&&e.dynamicCaption){if(e.currZoomLevel>e.zoomLevels.initial?this.hideCaption(e):this.showCaption(e),e.dynamicCaption.element){let i=0;if(e.currZoomLevel<=e.zoomLevels.initial){let n=e.pan.y-e.bounds.center.y;Math.abs(n)>1&&(i=n)}this.setCaptionYOffset(e.dynamicCaption.element,i)}this.adjustPanArea(e,e.currZoomLevel)}}),t.on("beforeZoomTo",e=>{this.adjustPanArea(t.currSlide,e.destZoomLevel)}),t.on("tapAction",e=>{e.originalEvent.target.closest(".pswp__dynamic-caption")&&e.preventDefault()})}adjustPanArea(t,e){t.dynamicCaption&&t.dynamicCaption.adjustedPanAreaSize&&(e>t.zoomLevels.initial?(t.panAreaSize.x=t.dynamicCaption.originalPanAreaSize.x,t.panAreaSize.y=t.dynamicCaption.originalPanAreaSize.y):(t.panAreaSize.x=t.dynamicCaption.adjustedPanAreaSize.x,t.panAreaSize.y=t.dynamicCaption.adjustedPanAreaSize.y))}useMobileLayout(){let{mobileLayoutBreakpoint:t}=this.options;return typeof t=="function"?t.call(this):typeof t=="number"&&window.innerWidth<t}hideCaption(t){if(t.dynamicCaption&&!t.dynamicCaption.hidden){let e=t.dynamicCaption.element;if(!e)return;t.dynamicCaption.hidden=!0,e.classList.add("pswp__dynamic-caption--faded"),t.captionFadeTimeout&&clearTimeout(t.captionFadeTimeout),t.captionFadeTimeout=setTimeout(()=>{e.style.visibility="hidden",delete t.captionFadeTimeout},400)}}setCaptionYOffset(t,e){t.style.transform=`translateY(${e}px)`}showCaption(t){if(t.dynamicCaption&&t.dynamicCaption.hidden){let e=t.dynamicCaption.element;if(!e)return;t.dynamicCaption.hidden=!1,e.style.visibility="visible",clearTimeout(t.captionFadeTimeout),t.captionFadeTimeout=setTimeout(()=>{e.classList.remove("pswp__dynamic-caption--faded"),delete t.captionFadeTimeout},50)}}setCaptionPosition(t,e,i){let n=e<=this.options.horizontalEdgeThreshold;t.classList[n?"add":"remove"]("pswp__dynamic-caption--on-hor-edge"),t.style.left=e+"px",t.style.top=i+"px"}setCaptionWidth(t,e){e?t.style.width=e+"px":t.style.removeProperty("width")}setCaptionType(t,e){let i=t.dataset.pswpCaptionType;e!==i&&(t.classList.add("pswp__dynamic-caption--"+e),t.classList.remove("pswp__dynamic-caption--"+i),t.dataset.pswpCaptionType=e)}updateCaptionPosition(t){if(!t.dynamicCaption||!t.dynamicCaption.type||!t.dynamicCaption.element)return;if(t.dynamicCaption.type==="mobile"){this.setCaptionType(t.dynamicCaption.element,t.dynamicCaption.type),t.dynamicCaption.element.style.removeProperty("left"),t.dynamicCaption.element.style.removeProperty("top"),this.setCaptionWidth(t.dynamicCaption.element,!1);return}let e=t.zoomLevels.initial,i=Math.ceil(t.width*e),n=Math.ceil(t.height*e);this.setCaptionType(t.dynamicCaption.element,t.dynamicCaption.type),t.dynamicCaption.type==="aside"?(this.setCaptionPosition(t.dynamicCaption.element,t.bounds.center.x+i,t.bounds.center.y),this.setCaptionWidth(t.dynamicCaption.element,!1)):t.dynamicCaption.type==="below"&&(this.setCaptionPosition(t.dynamicCaption.element,t.bounds.center.x,t.bounds.center.y+n),this.setCaptionWidth(t.dynamicCaption.element,i))}onCalcSlideSize(t){let{slide:e}=t,i,n;if(!e.dynamicCaption){e.dynamicCaption={element:void 0,type:!1,hidden:!1};let a=this.getCaptionHTML(e);if(!a)return;e.dynamicCaption.element=document.createElement("div"),e.dynamicCaption.element.className="pswp__dynamic-caption pswp__hide-on-close",e.dynamicCaption.element.innerHTML=a,this.pswp.dispatch("dynamicCaptionUpdateHTML",{captionElement:e.dynamicCaption.element,slide:e}),e.holderElement.appendChild(e.dynamicCaption.element)}if(!e.dynamicCaption.element)return;this.storeOriginalPanAreaSize(e),e.bounds.update(e.zoomLevels.initial),this.useMobileLayout()?(e.dynamicCaption.type="mobile",n=!0):this.options.type==="auto"?e.bounds.center.x>e.bounds.center.y?e.dynamicCaption.type="aside":e.dynamicCaption.type="below":e.dynamicCaption.type=this.options.type;let o=Math.ceil(e.width*e.zoomLevels.initial),m=Math.ceil(e.height*e.zoomLevels.initial);if(this.setCaptionType(e.dynamicCaption.element,e.dynamicCaption.type),e.dynamicCaption.type==="aside"){this.setCaptionWidth(e.dynamicCaption.element,!1),i=this.measureCaptionSize(e.dynamicCaption.element,t.slide);let a=i.x,p=o+e.bounds.center.x;e.panAreaSize.x-p<=a&&(e.panAreaSize.x-=a,this.recalculateZoomLevelAndBounds(e))}else if(e.dynamicCaption.type==="below"||n){this.setCaptionWidth(e.dynamicCaption.element,n?this.pswp.viewportSize.x:o),i=this.measureCaptionSize(e.dynamicCaption.element,t.slide);let a=i.y;if(this.options.verticallyCenterImage)e.panAreaSize.y-=a,this.recalculateZoomLevelAndBounds(e);else{let p=m+e.bounds.center.y,c=e.panAreaSize.y-p,r=e.panAreaSize.y;if(c<=a){e.panAreaSize.y-=Math.min((a-c)*2,a),this.recalculateZoomLevelAndBounds(e);let d=e.panAreaSize.x*this.options.mobileCaptionOverlapRatio/2;n&&e.bounds.center.x>d&&(e.panAreaSize.y=r,this.recalculateZoomLevelAndBounds(e))}}}this.storeAdjustedPanAreaSize(e),this.updateCaptionPosition(e)}measureCaptionSize(t,e){let i=t.getBoundingClientRect();return this.pswp.dispatch("dynamicCaptionMeasureSize",{captionEl:t,slide:e,captionSize:{x:i.width,y:i.height}}).captionSize}recalculateZoomLevelAndBounds(t){t.zoomLevels.update(t.width,t.height,t.panAreaSize),t.bounds.update(t.zoomLevels.initial)}storeAdjustedPanAreaSize(t){t.dynamicCaption&&(t.dynamicCaption.adjustedPanAreaSize||(t.dynamicCaption.adjustedPanAreaSize={}),t.dynamicCaption.adjustedPanAreaSize.x=t.panAreaSize.x,t.dynamicCaption.adjustedPanAreaSize.y=t.panAreaSize.y)}storeOriginalPanAreaSize(t){t.dynamicCaption&&(t.dynamicCaption.originalPanAreaSize||(t.dynamicCaption.originalPanAreaSize={}),t.dynamicCaption.originalPanAreaSize.x=t.panAreaSize.x,t.dynamicCaption.originalPanAreaSize.y=t.panAreaSize.y)}getCaptionHTML(t){if(typeof this.options.captionContent=="function")return this.options.captionContent.call(this,t);let e=t.data.element,i="";if(e){let n=e.querySelector(this.options.captionContent);if(n)i=n.innerHTML;else{let o=e.querySelector("img");o&&(i=o.getAttribute("alt"))}}return i}},h=s;export{h as default};
2//# sourceMappingURL=photoswipe-dynamic-caption-plugin.esm-5CMK5AKF.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.