Snippet

Navigation glissante

1 réponses de la communauté

'use strict';

function slideOutNavBar ({$=jQuery, nav='nav', ul='ul', but='button', speed='fast'}) {
    // target the childern of the parent nav container
    const navBar = $(nav);
    const button = navBar.find(but);
    const panel = navBar.find(ul);

    if (!navBar) {
        console.error('Parent navbar not selected properly');
        return;
    }
    if (!button) {
            console.error('Parent navbar not selected properly');
            return;
    }
    if (!panel) {
            console.error('Parent navbar not selected properly');
            return;
    }
    button.click(() => {
        panel.slideToggle(speed);
    });
} 

slideOutNavBar({nav:'#access', ul:'#nav-panel', but:'#toggle'});