Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Created November 8, 2019 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklchaves/bbd7f88032c67582774fe4f6343f6ff4 to your computer and use it in GitHub Desktop.
Save marklchaves/bbd7f88032c67582774fe4f6343f6ff4 to your computer and use it in GitHub Desktop.
Modified On Load JavaScript Code from kfrankc's Customisations of the Minimal Mistakes Jekyll Theme
// Refactored to support on load and resize calls. ~mlc
function loadMasonry() {
// console.log("Inside portfolio-masonry.js");
var grid = $('.grid__item');
var container = document.querySelector('.archive');
// Get reference to loading screen
var loading_screen = document.getElementById('loading');
imagesLoaded(container, function() {
grid.fadeIn();
var msnry = new Masonry(document.querySelector('.archive'), {
columnWidth: 100,
itemSelector: '.grid__item',
percentPosition: true,
horizontalOrder: true,
});
});
}
$(window).on('load', function() {
loadMasonry();
});
// Added this call to fix switching to mobile view. ~mlc
$(window).on('resize', function() {
loadMasonry();
});
function hideLoading(loading_screen) {
loading_screen.classList.add('hidden');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment