Created
March 31, 2017 13:08
-
-
Save 1v/2f357bfb4f451c655608ec2c0ff2c525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resize_images = (resize = false) -> | |
resize_single = (that) -> | |
if that.height() <= 200 | |
that.css({'width': 'auto', 'height': '100%'}) | |
else | |
that.css({'width': '100%', 'height': 'auto'}) | |
resize_process = (that) -> | |
# change dimensions to original | |
that.css({'width': 'auto', 'height': 'auto'}) | |
# fit parent box | |
resize_single(that) | |
# scaling for fill | |
resize_single(that) | |
images = $('.image img') | |
images.each -> | |
if resize | |
resize_process($(this)) | |
else | |
$(this).load -> | |
resize_process($(this)) | |
resize_images() | |
$(window).resize -> | |
resize_images(true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment