Created
November 8, 2019 15:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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