Skip to content
Snippets Groups Projects

Issue #3343994: Drupal 10 compatiility?

3 unresolved threads
Open Ann Mary Sruthy requested to merge issue/masonry-3343994:8.x-1.x into 8.x-1.x
3 unresolved threads
Files
4
+ 17
11
@@ -15,17 +15,20 @@
* (internal) Sub-function for code factoring: actually build masonry.
*/
function _buildMasonry($container, options) {
// Check if masonry already exists
let masonryExists = $container.hasClass('masonry');
Please register or sign in to reply
// If no masonry find in container: init it...
if ($container.findOnce('masonry').length === 0) {
$container.once('masonry').addClass('masonry').masonry(options);
if (!masonryExists) {
$container.addClass('masonry').masonry(options);
$(window).resize(function () {
$container.findOnce('masonry').masonry('bindResize');
$container.masonry('bindResize');
});
} else {
// ...otherwise, simply rebuild the layout.
$container.masonry('reloadItems').masonry('layout');
}
// Hack to support lazysizes lazy loading.
if (options.imagesLazyLoad) {
let lastClassState = false;
@@ -33,13 +36,13 @@
mutationsList.forEach(function(mutation) {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
let currentClassState = mutation.target.classList.contains(options.lazyloadedSelector);
if (lastClassState !== currentClassState) {
lastClassState = currentClassState;
if (currentClassState) {
if (options.imagesFirst) {
$container.imagesLoaded(function () {
imagesLoaded($container[0], function () {
$container.masonry('reloadItems').masonry('layout');
});
} else {
@@ -50,12 +53,15 @@
}
});
});
$('img.' + options.lazyloadSelector, $container).once('imgloaded').each(function() {
observer.observe(this, { attributes: true });
$('img.' + options.lazyloadSelector, $container).each(function() {
Please register or sign in to reply
if (!$(this).hasClass('imgloaded')) {
$(this).addClass('imgloaded');
observer.observe(this, { attributes: true });
}
});
}
}
}
/**
* Apply Masonry.
Loading