python-gallery/onlylegs/static/js/square.js
Michał e9e3706172 Move JS to layout HTML for faster loading
Keep images square through JS and not a bug with ::after
2023-04-22 13:45:29 +00:00

11 lines
380 B
JavaScript

function keepSquare() {
const images = document.querySelectorAll('.gallery-item');
for (let i = 0; i < images.length; i++) {
images[i].style.height = images[i].offsetWidth + 'px';
}
const groups = document.querySelectorAll('.group-item');
for (let i = 0; i < groups.length; i++) {
groups[i].style.height = groups[i].offsetWidth + 'px';
}
}