| Total Complexity | 2 |
| Complexity/F | 1 |
| Lines of Code | 21 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | // Used on both admin and public wander show pages |
||
| 2 | const $ = require('jquery'); |
||
| 3 | |||
| 4 | const Masonry = require('masonry-layout'); |
||
| 5 | const imagesLoaded = require('imagesloaded'); |
||
| 6 | |||
| 7 | $(() => { |
||
| 8 | const msnry = new Masonry('.gallery', { |
||
| 9 | itemSelector: '.grid-item', |
||
| 10 | gutter: 12, |
||
| 11 | }); |
||
| 12 | |||
| 13 | // layout Masonry after each image loads, and also keep it |
||
| 14 | // as well-hidden as possible until then by hiding its |
||
| 15 | // metadata div |
||
| 16 | $('.grid-item .metadata').hide(); |
||
| 17 | imagesLoaded(document.querySelector('.gallery')) |
||
| 18 | .on('progress', (instance, image) => { |
||
| 19 | $(image.img).closest('.grid-item').find('.metadata').show(); |
||
| 20 | msnry.layout(); |
||
| 21 | }); |
||
| 22 | }); |
||
| 23 |