-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.js
34 lines (27 loc) · 1.22 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* utils.js - holds utility functions used on more than one page */
/* Match heights of items on page based on incoming array of selectors */
function alignItems(selectors, skipSmall) {
var skip_small = (typeof skipSmall === 'undefined') ? true : skip_small;
// figure out width of screen
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
//wait a little bit before moving forward
setTimeout(function () {
$.each(selectors, function (index, selector) {
// First auto height things
var maxHeight = 'auto';
$(selector).height(maxHeight);
// next if larger than small devices, or if skipSmall is false find max-height and even things up
if (vw > 767 || !skip_small) {
var maxHeight = 0;
// loop through list of selectors to get maxHeight
$(selector).each(function () {
if ($(this).height() > maxHeight) {
maxHeight = $(this).height();
}
});
// set all of that selector to the same height
$(selector).height(maxHeight);
}
});
}, 300);
}