|
73 | 73 | var self = this;
|
74 | 74 | // Both enable and build methods require the body tag to be in the DOM.
|
75 | 75 | $(document).ready(function() {
|
76 |
| - self.enable(); |
77 |
| - self.build(); |
| 76 | + self.enable(); |
| 77 | + self.build(); |
78 | 78 | });
|
79 | 79 | };
|
80 | 80 |
|
|
99 | 99 | this.$overlay = $('#lightboxOverlay');
|
100 | 100 | this.$outerContainer = this.$lightbox.find('.lb-outerContainer');
|
101 | 101 | this.$container = this.$lightbox.find('.lb-container');
|
| 102 | + this.$image = this.$lightbox.find('.lb-image'); |
102 | 103 | this.$nav = this.$lightbox.find('.lb-nav')
|
103 | 104 |
|
104 | 105 | // Store css values for future lookup
|
105 |
| - this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10); |
106 |
| - this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10); |
107 |
| - this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10); |
108 |
| - this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10); |
| 106 | + this.containerPadding = { |
| 107 | + top: parseInt(this.$container.css('padding-top'), 10), |
| 108 | + right: parseInt(this.$container.css('padding-right'), 10), |
| 109 | + bottom: parseInt(this.$container.css('padding-bottom'), 10), |
| 110 | + left: parseInt(this.$container.css('padding-left'), 10) |
| 111 | + }; |
| 112 | + |
| 113 | + this.imageBorderWidth = { |
| 114 | + top: parseInt(this.$image.css('border-top-width'), 10), |
| 115 | + right: parseInt(this.$image.css('border-right-width'), 10), |
| 116 | + bottom: parseInt(this.$image.css('border-bottom-width'), 10), |
| 117 | + left: parseInt(this.$image.css('border-left-width'), 10) |
| 118 | + }; |
109 | 119 |
|
110 | 120 | // Attach event handlers to the newly minted DOM elements
|
111 | 121 | this.$overlay.hide().on('click', function() {
|
|
282 | 292 |
|
283 | 293 | windowWidth = $(window).width();
|
284 | 294 | windowHeight = $(window).height();
|
285 |
| - maxImageWidth = windowWidth - self.containerLeftPadding - self.containerRightPadding - 20; |
286 |
| - maxImageHeight = windowHeight - self.containerTopPadding - self.containerBottomPadding - 120; |
| 295 | + maxImageWidth = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20; |
| 296 | + maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - 120; |
287 | 297 |
|
288 | 298 | // Check if image size is larger then maxWidth|maxHeight in settings
|
289 | 299 | if (self.options.maxWidth && self.options.maxWidth < maxImageWidth) {
|
|
328 | 338 |
|
329 | 339 | var oldWidth = this.$outerContainer.outerWidth();
|
330 | 340 | var oldHeight = this.$outerContainer.outerHeight();
|
331 |
| - var newWidth = imageWidth + this.containerLeftPadding + this.containerRightPadding; |
332 |
| - var newHeight = imageHeight + this.containerTopPadding + this.containerBottomPadding; |
| 341 | + var newWidth = imageWidth + this.containerPadding.left + this.containerPadding.right + this.imageBorderWidth.left + this.imageBorderWidth.right; |
| 342 | + var newHeight = imageHeight + this.containerPadding.top + this.containerPadding.bottom + this.imageBorderWidth.top + this.imageBorderWidth.bottom; |
333 | 343 |
|
334 | 344 | function postResize() {
|
335 | 345 | self.$lightbox.find('.lb-dataContainer').width(newWidth);
|
|
0 commit comments