@All:

Ok. Here's a final solution for inverted hover accordion. hoverIntent plug
in is must. Structure is same as I posted earlier. Later during I will
upload it on web.
<script>
var radi1 = true;
var kd_opened;
var to_hide;
var height_op;

jQuery.easing.easeout = function(p, n, firstNum, delta, duration)
                        {
                            return -delta * ((n=n/duration-1)*n*n*n - 1) +
firstNum;
                        }

function otvoriSliku()
{

    if(!$(this).siblings(".naslov_stavke").is(":visible") && radi1 )
    {

        radi1 = false;
        to_hide = $(this).siblings(".naslov_stavke");
        to_hide.show().height(0);

        kd_opened.animate({height:"hide"},
                            {step: function(n){
                                to_hide.height(Math.ceil(height_op-n));
                                if(n == 0){kd_opened = to_hide;radi1 =
true;}
                            },
                            duration: 500,
                            easing: "easeout"
                        });
                        }
    }
$(document).ready(function()
{
    kd_opened = $(".naslov_stavke:first");
    height_op = kd_opened.height();

    $(".naslov_stavke:not(:first)").hide();

    $(".sadrzaj_stavke").hoverIntent({
        sensitivity: 1,
        interval: 50,
        over: otvoriSliku,
        out: function(){}
     });

});
</script>

Easing function is taken from Interface. Differences from  John's script
are:
1) John calculate height of opened "headers" before each animation. This
script calculates only once, on the beginning, to save some CPU cycles
2) Before animation, height of hidden "header" must be set to 0. This is
because of differences in behavior of inverted and real accordion.
3) In John script, if you try to click on "header" during animation, script
becomes nasty. Putting whole animation script in If(radi1) and checking with
if(n == 0){kd_opened = to_hide;radi1 = true;} I prevented run of new
animation before old one is finished.

@John:
You are such inspiration! Thanks man! Or: Hvala ti puno za sve , on my
native (Serbian)

Reply via email to