Completed
Push — master ( 3c1ff6...eff1c9 )
by Matt
16s queued 12s
created

assets/gallery.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 21
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2
mnd 0
bc 0
fnc 2
bpm 0
cpm 1
noi 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