fix: improve scripts and js

This commit is contained in:
Nuno Coração
2025-06-20 23:24:40 +01:00
parent 1f49f8f89f
commit 8c42d127ff
7 changed files with 228 additions and 207 deletions
+21 -2
View File
@@ -6,14 +6,33 @@ function _getDefaultPackeryOptions() {
};
}
function _getPackeryOptions(nodeGallery) {
const defaults = _getDefaultPackeryOptions();
const {
packeryGutter,
packeryPercentPosition,
packeryResize,
} = nodeGallery.dataset;
return {
percentPosition:
packeryPercentPosition !== undefined
? packeryPercentPosition === "true"
: defaults.percentPosition,
gutter:
packeryGutter !== undefined ? parseInt(packeryGutter, 10) : defaults.gutter,
resize:
packeryResize !== undefined ? packeryResize === "true" : defaults.resize,
};
}
(function init() {
$(window).on("load", function () {
let packeries = [];
let nodeGalleries = document.querySelectorAll(".gallery");
nodeGalleries.forEach((nodeGallery) => {
// TODO : implement a reader of Packery configuration _getPackeryOptions; for example by reading data-attribute
let packery = new Packery(nodeGallery, _getDefaultPackeryOptions());
let packery = new Packery(nodeGallery, _getPackeryOptions(nodeGallery));
packeries.push(packery);
});
console.groupEnd();