Created
May 3, 2017 19:32
-
-
Save imaginabit/bc1423b7472f15d277472911f1e5c726 to your computer and use it in GitHub Desktop.
Centre items in fullwitdh portfolio when they can fill the row
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
/* centra los portfolios */ | |
jQuery(function() { | |
reorder_items = function() { | |
console.log("reorder"); | |
var pf_total_items = 5; | |
if (jQuery(window).width() < 1599){ | |
pf_total_items = 4; | |
} | |
if (jQuery(window).width() < 1025){ | |
pf_total_items = 3; | |
} | |
if (jQuery(window).width() > 800) { | |
var pf_items = jQuery(".et_pb_fullwidth_portfolio").find(".et_pb_portfolio_item").size(); | |
if (pf_items <5 && pf_items >0){ | |
console.log("in parms"); | |
//var items_left = ((100 / pf_total_items) * (5 / pf_items)) / 2; | |
//var items_left = (20 * Math.ceil(pf_total_items / pf_items))/2 ; | |
var items_left = (100 - ((100/pf_total_items) * pf_items)) / 2; | |
console.log('((20 / '+pf_total_items+') * (5 / '+pf_items+')) / 2;'); | |
console.log('pf_total_items',pf_total_items); | |
console.log('item left',items_left); | |
console.log('mathceil: ', Math.ceil(pf_total_items / pf_items)); | |
//jQuery(".page").find(".et_pb_carousel_group").attr("style", "left:" + items_left + "%"); | |
jQuery(".et_pb_fullwidth_portfolio").find(".et_pb_portfolio_item").css("left", items_left + "%"); | |
} | |
} else { | |
jQuery(".et_pb_fullwidth_portfolio").find(".et_pb_portfolio_item").css("left", "0"); | |
} | |
}; | |
//when window resize recalculate | |
jQuery(window).on('load resize', reorder_items); | |
jQuery(".et_pb_fullwidth_portfolio").ready(reorder_items); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment