-
-
Save mikeadesign/3114513 to your computer and use it in GitHub Desktop.
Equal Height columns only if browser window is wider than 481px
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
// global variables | |
var compareWidthColumn, //previous width used for comparison | |
detectorColumn, //the element used to compare changes | |
smallScreenColumn; // Size of maximum width of single column media query | |
jQuery(document).ready(function($) { | |
//set the initial values | |
detectorColumn = jQuery('.js'); | |
compareWidthColumn = detectorColumn.width(); | |
smallScreenColumn = '481'; | |
if ($(window).width() > smallScreenColumn) { | |
$('.equal').matchHeights({ | |
minHeight: null, // optional minimum height setting | |
maxHeight: null, // optional maximum height setting, forced height instead of min-height | |
extension: 0, // optional amount to add to calculated height | |
overflow: false // optional setting for overflow. Default is false; overflow attribute not set | |
}); | |
}; | |
jQuery(window).resize(function() { | |
//compare everytime the window resize event fires | |
if (detectorColumn.width() != compareWidthColumn) { | |
//a change has occurred so update the comparison variable | |
compareWidthColumn = detector.width(); | |
if (compareWidthColumn > smallScreenColumn) { | |
// Remove inline style applied from matchHeights prior to reapplying matchHeights. | |
// This will remove any inline styles added. | |
$('.equal').removeAttr('style').matchHeights({ | |
minHeight: null, // optional minimum height setting | |
maxHeight: null, // optional maximum height setting, forced height instead of min-height | |
extension: 0, // optional amount to add to calculated height | |
overflow: false // optional setting for overflow. Default is false; overflow attribute not set | |
}); | |
} else { | |
// If above does not evaulate to true then remove any inline style to remove matchHeights applied height | |
$('.equal').removeAttr('style'); | |
}; | |
}; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment