Difference between revisions of "MediaWiki:Mobile.js"

no edit summary
Line 86: Line 86:
       }
       }
   }, 100); // check every 100ms
   }, 100); // check every 100ms
// ========================== Integrazione pagine Wix 2024 ==========================
function handleEntries(entries) {
    for (var i = 0; i < entries.length; i++) {
        var entry = entries[i];
        console.log(entry);
        if (entry.isIntersecting) {
            addClass(entry.target, 'fade-in-on-intersection');
        } else {
            removeClass(entry.target, 'fade-in-on-intersection');
        }
    }
}
function addClass(element, className) {
    if (element.className.indexOf(className) === -1) {
        element.className += ' ' + className;
    }
}
function removeClass(element, className) {
    element.className = element.className.replace(new RegExp('(?:^|\\s)' + className + '(?!\\S)'), '');
}
var observer = new IntersectionObserver(handleEntries);
var hiddenElements = document.querySelectorAll('.hidden-except-on-intersection');
for (var i = 0; i < hiddenElements.length; i++) {
    observer.observe(hiddenElements[i]);
}