diff --git a/package.json b/package.json index e089dbd..0daa832 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simplelightbox", - "version": "2.14.2", + "version": "2.14.3", "description": "Touch-friendly modern image lightbox for mobile and desktop with optional jQuery support", "main": "dist/simple-lightbox.js", "style": "dist/simple-lightbox.css", diff --git a/src/simple-lightbox.js b/src/simple-lightbox.js index 47a5687..434bba3 100644 --- a/src/simple-lightbox.js +++ b/src/simple-lightbox.js @@ -627,6 +627,10 @@ class SimpleLightbox { imageHeight /= ratio; } + const imageStyle = window.getComputedStyle(this.domNodes.image); + imageWidth += parseFloat(imageStyle.borderLeftWidth) + parseFloat(imageStyle.borderRightWidth); + imageHeight += parseFloat(imageStyle.borderTopWidth) + parseFloat(imageStyle.borderBottomWidth); + this.domNodes.image.style.top = (window.innerHeight - imageHeight) / 2 + 'px'; this.domNodes.image.style.left = (window.innerWidth - imageWidth - this.globalScrollbarWidth) / 2 + 'px'; this.domNodes.image.style.width = imageWidth + 'px';