Pull carousels array out into a variable and bail early if there are no carousels
This commit is contained in:
parent
00d2e9263d
commit
af957c0150
1 changed files with 11 additions and 1 deletions
|
@ -171,6 +171,16 @@ class PhotoParametersTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", (event) => {
|
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;
|
let photoParams = null;
|
||||||
|
|
||||||
const photoParamsTableElement = document.querySelector(".photo-params table");
|
const photoParamsTableElement = document.querySelector(".photo-params table");
|
||||||
|
@ -178,7 +188,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
photoParams = new PhotoParametersTable(photoParamsTableElement);
|
photoParams = new PhotoParametersTable(photoParamsTableElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelectorAll("figure.carousel").forEach(carouselElement => {
|
allCarousels.forEach(carouselElement => {
|
||||||
class CarouselItem {
|
class CarouselItem {
|
||||||
element = null;
|
element = null;
|
||||||
relativeX = 0;
|
relativeX = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue