Created
October 29, 2012 19:10
-
-
Save rezozero/3975814 to your computer and use it in GitHub Desktop.
JS: Compute deployed article images
This file contains hidden or 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
| /** | |
| * Copyright REZO ZERO 2012 | |
| * | |
| * This work is licensed under the Creative Commons Attribution-NoDerivs 2.0 France License. | |
| * To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/2.0/fr/ | |
| * or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. | |
| * | |
| * Compute collection images height in order to make them enter in a given width | |
| * We need to know default images height and the given final width | |
| * | |
| * @file | |
| * @copyright REZO ZERO 2012 | |
| * @author Ambroise Maupate | |
| */ | |
| function computeDeployedArticleImages ( article ) | |
| { | |
| var startHeight = 300; | |
| var computedWidth = 0; | |
| var endWidth = 602; | |
| if ($(article).find(".img_container img").length > 1) { | |
| $(article).find(".img_container img").each(function (index) { | |
| computedWidth += $(this).actual("outerWidth",{includeMargin:true}); | |
| }); | |
| var ratio = computedWidth/startHeight; | |
| var endHeight = endWidth/ratio; | |
| $(article).find(".img_container img").css("height", endHeight+"px"); | |
| }else { | |
| $(article).find(".img_container").css("height", "300px"); | |
| } | |
| $(article).find(".img_container").slideDown(750); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment