Pull carousels array out into a variable and bail early if there are no carousels

This commit is contained in:
Eryn Wells 2023-04-02 19:45:23 -07:00
parent 00d2e9263d
commit af957c0150

View file

@ -171,6 +171,16 @@ class PhotoParametersTable {
}
document.addEventListener("DOMContentLoaded", (event) => {
let allCarousels = Array.from(document.querySelectorAll("figure.carousel")).sort((a, b) => {
const aRect = a.getBoundingClientRect();
const bRect = a.getBoundingClientRect();
return aRect.top - bRect.top;
});
if (allCarousels.length === 0) {
return;
}
let photoParams = null;
const photoParamsTableElement = document.querySelector(".photo-params table");
@ -178,7 +188,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
photoParams = new PhotoParametersTable(photoParamsTableElement);
}
document.querySelectorAll("figure.carousel").forEach(carouselElement => {
allCarousels.forEach(carouselElement => {
class CarouselItem {
element = null;
relativeX = 0;