Domanda

Hi everyone i created a small code to animate a box (show,hide) and something wrong with my code i can't find the right solution... if i create a simple click function it works but i won't create two different clicks so I'm using toggle function.

(Im using query transit to scale to 0 the box)

$(document).ready( function() {
$("#mobile_bar").clickToggle(function() {   
    $("#navigation_box").fadeIn(500);
},
function() {
    $("#navigation_box").transition({ scale: 0, delay: 500 });
}); });

Thank you

È stato utile?

Soluzione

You could use:

$(document).ready(function () {
    $("#mobile_bar").click(function () {
        var $navBox = $("#navigation_box").clearQueue();
        if (!$(this).data('toggle')) {
            $navBox.fadeIn(500);
        } else {
            $navBox.transition({
                scale: 0,
                delay: 500
            });
        }
        $(this).data('toggle', !$(this).data('toggle'));
    });
});

PS: not sure transition plugin uses the fx queue or not?!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top