andygott / Really-Simple-Slideshow

A jQuery slideshow plugin that loads images as they're required to save bandwidth.
http://reallysimpleworks.com/slideshow/
MIT License
47 stars 15 forks source link

Added "fit" option to scale images to fit container #25

Open Jalon opened 11 years ago

Jalon commented 11 years ago

Immediately after

                                var whenDimensions = function(width, height) {

Add this block:

                if (data.settings.fit === true)
                {
                    var ratio = Math.min(containerWidth/width, containerHeight/height);
                    width = Math.ceil(ratio * width);
                    height = Math.ceil(ratio * height);
                    $img.css({width: width});
                    $img.css({height: height});
                }