Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: When displaying SVGs, max out their size #684

Merged
merged 2 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <lokesh.dhakar@gmail.com>",
"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