• Resolved thomas2070

    (@thomas2070)


    I’ve updated all my photo pages on my website to use the Spectra image gallery. It runs smoothly and is less bloated than the dedicated plugin I used before. However, I’m wondering if there’s a way to preload the next images when using the slideshow? This was a standard feature in my previous plugin, Modula, which greatly enhanced the user experience. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @thomas2070,

    Thanks for getting in touch with us.

    I am afraid it is not possible with the provided options. We’d love to take this as a suggestion. I will surely convey your feedback to our concerned developers. We are always keen to listen to our customers and to receive their feedback. This is the best way to improve our products and services and maintain our client’s satisfaction. 🙂

    Have a nice day!

    Thread Starter thomas2070

    (@thomas2070)

    Hi @mohsinbsf

    Thanks for your message. I’ve added a small Javascript snippet to my slideshow that does the trick for now. It doesn’t interfere with the original code but monitors any changes in the slideshow div classes. Basically, when ‘swiper-slide-next’ is added, the image is preloaded. This tweak has significantly improved the UX, so I hope you’ll consider incorporating something similar into the product roadmap permanently. I’ve included the code below in case it’s helpful for anyone else.

    Thanks for considering this!

    Best, Thomas

    document.addEventListener("DOMContentLoaded", function () {
        function preloadImage(imgElement) {
            if (imgElement && imgElement.dataset.src && !imgElement.src) {
                imgElement.src = imgElement.dataset.src;
                imgElement.removeAttribute('data-src');
            }
        }
    
        var callback = function (mutationsList, observer) {
            for (var mutation of mutationsList) {
                if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
                    var targetElement = mutation.target;
                    if (targetElement.classList.contains('swiper-slide-next')) {
                        var imgElement = targetElement.querySelector('img');
                        preloadImage(imgElement);
                    }
                }
            }
        };
    
        var observer = new MutationObserver(callback);
        var config = { attributes: true, subtree: true, attributeFilter: ['class'] };
        var targetNode = document.querySelector('.swiper-wrapper');
        if (targetNode) {
            observer.observe(targetNode, config);
        }
    });
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Spectra – image gallery preloader’ is closed to new replies.