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 @@
@@ -15,17 +15,20 @@
* (internal) Sub-function for code factoring: actually build masonry.
* (internal) Sub-function for code factoring: actually build masonry.
*/
*/
function _buildMasonry($container, options) {
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 no masonry find in container: init it...
if ($container.findOnce('masonry').length === 0) {
if (!masonryExists) {
$container.once('masonry').addClass('masonry').masonry(options);
$container.addClass('masonry').masonry(options);
$(window).resize(function () {
$(window).resize(function () {
$container.findOnce('masonry').masonry('bindResize');
$container.masonry('bindResize');
});
});
} else {
} else {
// ...otherwise, simply rebuild the layout.
// ...otherwise, simply rebuild the layout.
$container.masonry('reloadItems').masonry('layout');
$container.masonry('reloadItems').masonry('layout');
}
}
// Hack to support lazysizes lazy loading.
// Hack to support lazysizes lazy loading.
if (options.imagesLazyLoad) {
if (options.imagesLazyLoad) {
let lastClassState = false;
let lastClassState = false;
@@ -33,13 +36,13 @@
@@ -33,13 +36,13 @@
mutationsList.forEach(function(mutation) {
mutationsList.forEach(function(mutation) {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
let currentClassState = mutation.target.classList.contains(options.lazyloadedSelector);
let currentClassState = mutation.target.classList.contains(options.lazyloadedSelector);
if (lastClassState !== currentClassState) {
if (lastClassState !== currentClassState) {
lastClassState = currentClassState;
lastClassState = currentClassState;
if (currentClassState) {
if (currentClassState) {
if (options.imagesFirst) {
if (options.imagesFirst) {
$container.imagesLoaded(function () {
imagesLoaded($container[0], function () {
$container.masonry('reloadItems').masonry('layout');
$container.masonry('reloadItems').masonry('layout');
});
});
} else {
} else {
@@ -50,12 +53,15 @@
@@ -50,12 +53,15 @@
}
}
});
});
});
});
$('img.' + options.lazyloadSelector, $container).once('imgloaded').each(function() {
$('img.' + options.lazyloadSelector, $container).each(function() {
Please register or sign in to reply
observer.observe(this, { attributes: true });
if (!$(this).hasClass('imgloaded')) {
 
$(this).addClass('imgloaded');
 
observer.observe(this, { attributes: true });
 
}
});
});
}
}
}
}
/**
/**
* Apply Masonry.
* Apply Masonry.
Loading