JohnPaulDesign
5/1/2017 - 4:49 PM

Play animation and reverse faster (Good for pop out nav)

Play animation and reverse faster (Good for pop out nav)

//Used on Johnpaul.design

jQuery(function () {
    "use strict";

    //Open the navgation menu
    //Paused by default. onStart resets the speed to 1 because the close button sets the speed to x3 while reversing it
    var navIn = new TimelineMax({paused: true, onStart: function () {navIn.timeScale(1);}});
    navIn.to(".site-inner", 1, {x: -50, delay: 0.2, ease: Power3.easeOut})
    .set(".nav-primary ul", {clearProps: "scale"})
        .to(".hamburger", 0.3, {autoAlpha: 0, ease: Power3.easeInOut}, 0)
        .to(".close-menu", 0.3, {autoAlpha: 1, ease: Power3.easeInOut}, 0.3)
        .to(".nav-primary", 0.3, {autoAlpha: 1, ease: Power3.easeInOut}, 0)
        .staggerFromTo(".nav-primary li", 0.8, {autoAlpha: 0, x: 25, y: -25}, {autoAlpha: 1, x: 0, y: 0, ease: Power3.easeOut, delay: 0.2}, 0.08, 0);

    jQuery("#navToggle").click(function () {
        navIn.play();
    });

    jQuery("#closeNav").click(function () {
        navIn.timeScale(3).reverse();
        //Reverses the timeline and triples the speed
    });

    
});