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

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

Open
Jalon opened this issue Dec 12, 2012 · 0 comments
Open

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

Jalon opened this issue Dec 12, 2012 · 0 comments

Comments

@Jalon
Copy link

Jalon commented Dec 12, 2012

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});
                }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant