Skip to content

Commit

Permalink
Merge pull request #684 from lokesh/dev
Browse files Browse the repository at this point in the history
feat: When displaying SVGs, max out their size
  • Loading branch information
lokesh authored Jul 7, 2020
2 parents 85dd34f + 02eb8ee commit 7734213
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightbox2",
"version": "2.11.1",
"version": "2.11.2",
"author": "Lokesh Dhakar <[email protected]>",
"description": "The original Lightbox script. Uses jQuery.",
"keywords": [
Expand Down
17 changes: 6 additions & 11 deletions src/js/lightbox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Lightbox v2.11.1
* Lightbox v2.11.2
* by Lokesh Dhakar
*
* More info:
Expand Down 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 7734213

Please sign in to comment.