Pythalex
2/22/2019 - 3:36 PM

Javascript - fold unfold

Fold and unfold a section in js

async function fold_switch(id){
    let section = jQuery("#" + id);
    let visibility = section.css("visibility");

    if (visibility === "hidden"){
        unfold(section);
    } else {
        fold(section);
    }
}

async function fold(section){
    section.animate({
        visibility : "hidden",
        height: "toggle"
    }, 500, function(){

    });
}

async function unfold(section){
    section.animate({
        visibility : "visible",
        height: "toggle"
    }, 500, function(){

    });
}