Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using diagonal discriminant for image resizing, per issue 1

  • Loading branch information...
commit cbaa9135a17ae60197d76e90715bf054f8b19ac9 1 parent fa02d77
@krewenki authored
Showing with 12 additions and 10 deletions.
  1. +12 −10 jquery.lightbox.js
View
22 jquery.lightbox.js
@@ -194,16 +194,18 @@
var initialPageWidth = arrayPageSize[2] - 2 * opts.borderSize;
var initialPageHeight = arrayPageSize[3] - 200;
- if (imgPreloader.height > initialPageHeight)
- {
- newWidth = parseInt((initialPageHeight/imgPreloader.height) * imgPreloader.width);
- newHeight = initialPageHeight;
- }
- else if (imgPreloader.width > initialPageWidth)
- {
- newHeight = parseInt((initialPageWidth/imgPreloader.width) * imgPreloader.height);
- newWidth = initialPageWidth;
- }
+ var dI = initialPageWidth/initialPageHeight;
+ var dP = imgPreloader.width/imgPreloader.height;
+
+ if((imgPreloader.height > initialPageHeight) || (imgPreloader.width > initialPageWidth)){
+ if(dI > dP){
+ newWidth = parseInt((initialPageHeight/imgPreloader.height) * imgPreloader.width);
+ newHeight = initialPageHeight;
+ } else {
+ newHeight = parseInt((initialPageWidth/imgPreloader.width) * imgPreloader.height);
+ newWidth = initialPageWidth;
+ }
+ }
}
$('#lightboxImage').attr('src', opts.imageArray[opts.activeImage][0])
Please sign in to comment.
Something went wrong with that request. Please try again.