-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmansory.js
26 lines (22 loc) · 944 Bytes
/
mansory.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
// @ts-check
function resizeGridItem(item) {
var grid = document.getElementsByClassName("grid")[0];
var rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows'));
var rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap'));
var rowSpan = Math.ceil((item.querySelector('.gridContent').getBoundingClientRect().height + rowGap) / (rowHeight + rowGap));
item.style.gridRowEnd = "span " + rowSpan;
}
function resizeAllGridItems() {
var allItems = document.getElementsByClassName("gridItem");
for (var x = 0; x < allItems.length; x++) {
resizeGridItem(allItems[x]);
// for (var x = 0; x < allItems.length; x++) {
// imagesLoaded(allItems[x], resizeInstance);
// }
}
}
function resizeInstance(instance) {
var item = instance.elements[0];
resizeGridItem(item);
}
window.addEventListener("resize", resizeAllGridItems);