Sha256: 622f2e19180c619b266692df68642219a37f30362572a859818f8e306973d323

Contents?: true

Size: 1.88 KB

Versions: 19

Compression:

Stored size: 1.88 KB

Contents

function fadeInPage() {
        if (!window.AnimationEvent) { return; }
        
        let contentFader = document.getElementById('content-fader');
        let sidebarFader = document.getElementById('sidebar-fader');

        contentFader.classList.add('fade-out');
        sidebarFader.classList.add('fade-out');
    }

document.addEventListener("DOMContentLoaded", function() {
    if (!window.AnimationEvent) { return; }

    let links = document.getElementsByClassName("fade-onclick");
    for (let i = 0; i < links.length; i += 1) {
        links[i].addEventListener("click", function(event) {
            let contentFader = document.getElementById("content-fader"),
                sidebarFader = document.getElementById("sidebar-fader"),
                anchor = event.currentTarget;
            
            let listener = function() {
                window.location = anchor.href;
                contentFader.removeEventListener("animationend", listener);
                sidebarFader.removeEventListener("animationend", listener);
            };
            contentFader.addEventListener("animationend", listener);
            sidebarFader.addEventListener("animationend", listener);
            
            event.preventDefault();
            contentFader.classList.add("fade-in");
            sidebarFader.classList.add("fade-in");
        });
    }
});
    
// Remove class in case of page being cached, add class for page navigation through means other than links (eg refresh, back/forward)
window.addEventListener("pageshow", function (event) {
    if (!event.persisted) {
        return;
    }
    let contentFader = document.getElementById("content-fader");
    let sidebarFader = document.getElementById("sidebar-fader");

    contentFader.classList.remove("fade-in");
    sidebarFader.classList.remove("fade-in");

    contentFader.classList.add("fade-out");
    sidebarFader.classList.add("fade-out");
});

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
arco-0.8.2 assets/js/fade-transitions.js
arco-0.8.1 assets/js/fade-transitions.js
arco-0.8.0 assets/js/fade-transitions.js
arco-0.7.0 assets/js/fade-transitions.js
arco-0.6.5 assets/js/fade-transitions.js
arco-0.6.3 assets/js/fade-transitions.js
arco-0.6.1 assets/js/fade-transitions.js
arco-0.6.0 assets/js/fade-transitions.js
arco-0.5.0 assets/js/fade-transitions.js
arco-0.4.4 assets/js/fade-transitions.js
arco-0.4.3 assets/js/fade-transitions.js
arco-0.4.2 assets/js/fade-transitions.js
arco-0.4.1 assets/js/fade-transitions.js
arco-0.4.0 assets/js/fade-transitions.js
arco-0.3.2 assets/js/fade-transitions.js
arco-0.3.1 assets/js/fade-transitions.js
arco-0.3.0 assets/js/fade-transitions.js
arco-0.2.0 assets/js/fade-transitions.js
arco-0.1.1 assets/js/fade-transitions.js