// masonry var minWidth = 209; var $masonry = $('#masonry'); // Setup Masonry behavior function masonry_update() { var flag; if ($('html').width() < minWidth) { $masonry.masonry('destroy'); flag = 0; } else { // Initialize Masonry after loading images have been completed. $masonry.imagesLoaded(function() { $masonry.masonry({ itemSelector: '.item', isFitWidth: true, isAnimated: true }); }); } } masonry_update(); // Initialize LazyLoad var $lazy = $('img.lazy'); $lazy.lazyload({ effect: 'fadeIn', effectspeed: 1000 }); // Refresh Masonry after LazyLoad images have been loaded. // cite: http://stackoverflow.com/questions/11398005/jquery-lazyload-callback $lazy.on('load', function() { masonry_update(); }); // Update Masonry if the window width is changed var timer = false; $(window).resize(function(){ if (timer !== false) { clearTimeout(timer); } timer = setTimeout(function() { masonry_update(); }, 200); }); // Initialize MagnificPopup $masonry.magnificPopup({ delegate: 'a', type: 'image', disableOn: function() { if($(window).width() < minWidth) { return false; } return true; }, // Gallery Option gallery: { enabled: true }, // image Content-type Option image: { cursor: null, titleSrc: 'data-category' } });