Skip to content

Commit

Permalink
feat: When displaying SVGs, max out their size
Browse files Browse the repository at this point in the history
  • Loading branch information
lokesh committed Jul 4, 2020
1 parent 85dd34f commit 5210ca2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lightbox2

The original lightbox script. Eight years later — still going strong!
The _original_ lightbox script.

Lightbox is small javascript library used to overlay images on top of the current page. It's a snap to setup and works on all modern browsers.

Expand Down
15 changes: 5 additions & 10 deletions src/js/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,13 @@
maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - self.options.positionFromTop - 70;

/*
SVGs that don't have width and height attributes specified are reporting width and height
values of 0 in Firefox 47 and IE11 on Windows. To fix, we set the width and height to the max
dimensions for the viewport rather than 0 x 0.
https://github.com/lokesh/lightbox2/issues/552
Since many SVGs have small intrinsic dimensions, but they support scaling
up without quality loss because of their vector format, max out their
size.
*/

if (filetype === 'svg') {
if ((preloader.width === 0) || preloader.height === 0) {
$image.width(maxImageWidth);
$image.height(maxImageHeight);
}
$image.width(maxImageWidth);
$image.height(maxImageHeight);
}

// Fit image inside the viewport.
Expand Down

0 comments on commit 5210ca2

Please sign in to comment.