Необходим совет по загрузке изображений на зацикленной страницеJquery

Программирование на jquery
Ответить
Anonymous
 Необходим совет по загрузке изображений на зацикленной странице

Сообщение Anonymous »

У меня есть страница галереи с использованием плагина WordPress Image Photo Gallery Final Tiles Grid.
Я хочу, чтобы страница/прокрутка постоянно повторялась (поэтому, когда пользователь прокручивает страницу вниз, галерея повторяется.
Следующий скрипт, кажется, хорошо повторяет, но изображения не загружаются, и я не могу в этом разобраться, есть идеи?

Код: Выделить всё

jQuery(document).ready(function($) {
const $gallery = $(".final-tiles-gallery");
const originalContent = $gallery.html(); // Save the original gallery content

// Function to append the content again
function appendContent() {
$gallery.append(originalContent); // Duplicate the gallery content

// Re-initialize the gallery plugin after appending new content
setTimeout(function() {
// Trigger the gallery plugin to reprocess the newly added images
if (typeof jQuery.fn.ftgInit === 'function') {
$gallery.ftgInit(); // This is specific to the Final Tiles Gallery plugin
}

// Ensure the gallery layout is recalculated after new images are appended
const instance = $gallery.data('ftg-instance'); // Get the gallery instance
if (instance) {
instance.setCurrentColumnSize(); // Recalculate column size for layout
instance.setCurrentImageSizeFactor(); // Adjust image size factor for new content
instance.setCurrentGridSize(); // Adjust grid size for the new layout
instance.refresh(); // Recalculate and refresh layout
}
}, 100); // Adjust the timeout delay as needed
}

// Trigger infinite scroll
jQuery(window).on("scroll", function() {
const scrollPosition = jQuery(window).scrollTop() + jQuery(window).height(); // Current scroll position
const documentHeight = jQuery(document).height(); // Total document height

// If the user scrolls near the bottom, append more content
if (scrollPosition >= documentHeight - 100) {
appendContent();
}
});
});
Вот страница, если это поможет...
Циклическая галерея
Большое спасибо (заранее)!

Подробнее здесь: https://stackoverflow.com/questions/792 ... oping-page
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»