I'm using Jquery to keep my aspect ratio when re-sizing. On small screens i want to use this script on a different class. It all seems to work just fine on first load.
But when i resize my window from big >768 to small < 767 the script wont work unless i reload. Strangely when i load the site in a small window <767 and resize it to big >768 the script does work and keeps working when re-sizing. Any idea how to resolve this?
if ($(window).width() > 768) {
/* square featured-column1 box aanpassing */
equalheight = function(container) {
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).each(function() {
$el = $(this);
$($el).height('auto')
topPostion = $el.position().top;
if (currentRowStart != topPostion) {
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPostion;
currentTallest = $el.height();
rowDivs.push($el);
} else {
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
}
$(window).load(function() {
equalheight('.featured-column');
});
$(window).resize(function() {
equalheight('.featured-column');
});
/* Aspect ratio box (responsive rechthoek) aanpassing */
$(document).ready(function() {
aspectResize();
$(window).resize(aspectResize);
});
aspectResize = function() {
var $aspect = $('div.up-to-date-bar');
var width = $aspect.width();
$aspect.height(width / 3 * 1);
}
}
/* Aspect ratio box (responsive rechthoek) aanpassing up-to-date-column*/
if ($(window).width() < 767) {
$(document).ready(function() {
aspectResize();
$(window).resize(aspectResize);
});
aspectResize = function() {
var $aspect = $('div.up-to-date-column');
var width = $aspect.width();
$aspect.height(width / 1 * 1);
}
}