Skip to content

Commit

Permalink
Merge pull request #1296 from StandingPadAnimations/gallery-magic-grid
Browse files Browse the repository at this point in the history
Gallery: Switch Packery to MagicGrid
  • Loading branch information
nunocoracao authored Mar 9, 2024
2 parents 263a1dc + f93ac47 commit 08b14e9
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 68 deletions.
22 changes: 10 additions & 12 deletions assets/js/shortcodes/gallery.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
function _getDefaultPackeryOptions() {
return {
percentPosition: true,
gutter: 5,
resize: true
};
}

(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());
packeries.push(packery);
let magicGrid = new MagicGrid({
container: nodeGallery,
static: true,
gutter: 5,
animate: false,
});
magicGrid.listen();
magicGrids.push(magicGrid);
});
console.log("Galleries founded and initialized with MagicGrid", magicGrids);
console.groupEnd();
});
})();
})();
1 change: 1 addition & 0 deletions assets/lib/magic-grid/magic-grid.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions assets/lib/packery/packery.pkgd.min.js

This file was deleted.

6 changes: 3 additions & 3 deletions layouts/partials/vendor.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

{{/* Packery */}}
{{ if .Page.HasShortcode "gallery" }}
{{ $packeryLib := resources.Get "lib/packery/packery.pkgd.min.js" }}
<script defer src="{{ $packeryLib.RelPermalink }}" integrity="{{ $packeryLib.Data.Integrity }}"></script>
{{ $magicGridLib := resources.Get "lib/magic-grid/magic-grid.min.js" }}
<script defer src="{{ $magicGridLib.RelPermalink }}" integrity="{{ $magicGridLib.Data.Integrity }}"></script>

{{ $jsShortcodeGallery := resources.Get "js/shortcodes/gallery.js" }}
{{ $jsShortcodeGallery = $jsShortcodeGallery | resources.Minify | resources.Fingerprint "sha512" }}
Expand All @@ -64,4 +64,4 @@
{{ if or (.Page.HasShortcode "carousel") (.Page.HasShortcode "timeline")}}
{{ $twelementsLib := resources.Get "lib/tw-elements/index.min.js" }}
<script defer src="{{ $twelementsLib.RelPermalink }}" integrity="{{ $twelementsLib.Data.Integrity }}"></script>
{{ end }}
{{ end }}
91 changes: 54 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"fuse.js": "^7.0.0",
"jquery": "^3.7.1",
"katex": "^0.16.9",
"magic-grid": "^3.2.4",
"mermaid": "^10.9.0",
"packery": "^2.1.2",
"prettier": "^3.2.5",
"prettier-plugin-go-template": "^0.0.15",
"prettier-plugin-tailwindcss": "^0.5.11",
Expand Down Expand Up @@ -90,8 +90,8 @@
"to": "assets/lib/jquery/jquery.slim.min.js"
},
{
"from": "node_modules/packery/dist/packery.pkgd.min.js",
"to": "assets/lib/packery/packery.pkgd.min.js"
"from": "node_modules/magic-grid/dist/magic-grid.min.js",
"to": "assets/lib/magic-grid/magic-grid.min.js"
},
{
"from": "node_modules/tw-elements/js/tw-elements.umd.min.js",
Expand Down

0 comments on commit 08b14e9

Please sign in to comment.