From 83885edbbc9be003323254b5763ce129f4829eab Mon Sep 17 00:00:00 2001 From: Andreas Blaesius Date: Sun, 6 Sep 2020 10:15:39 +0200 Subject: [PATCH] seems to work --- src/js/ui/photoswipe-ui-default.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/js/ui/photoswipe-ui-default.js b/src/js/ui/photoswipe-ui-default.js index c15421ae5..9ac0d659b 100644 --- a/src/js/ui/photoswipe-ui-default.js +++ b/src/js/ui/photoswipe-ui-default.js @@ -50,7 +50,20 @@ loadingIndicatorDelay: 1000, // 2s addCaptionHTMLFn: function (item, captionElement /*, isFake */) { + var captionCtrl = pswp.scrollWrap.querySelector('.pswp__button--caption--ctrl'); + var captionElement = captionCtrl.parentNode; var innerCaptionElement = captionElement.querySelector('.pswp__caption__center'); + var imagePositionTop; + if (item.initialPosition) { + imagePositionTop = item.initialPosition.y; + } else { + imagePositionTop = 0; + } + var apparentImageHeight = Math.round(item.h * item.initialZoomLevel); + var gapTop = item.vGap; + var naturalCaptionHeight = innerCaptionElement.clientHeight; + var layoutData = _getLayoutData(captionElement); + if (!item.title) { innerCaptionElement.innerHTML = ''; return false; @@ -59,17 +72,8 @@ // If allowLongCaptions is true, position caption just under picture and show "Expand" button if necessary if (_options.allowLongCaptions) { - var imagePositionTop = item.initialPosition.y; - var apparentImageHeight = Math.round(item.h * item.initialZoomLevel); - var gapTop = item.vGap.top; - ui.resetCaption(); - var naturalCaptionHeight = innerCaptionElement.clientHeight; - - var captionCtrl = captionElement.querySelector('.pswp__button--caption--ctrl'); - _setLayoutData(captionElement, imagePositionTop, apparentImageHeight, gapTop, naturalCaptionHeight); - var layoutData = _getLayoutData(captionElement); // Show the 'expand' control only if caption extends out of view. Reset height first. if (naturalCaptionHeight - 10 > layoutData.maxCollapsedCaptionHeight) {