accordion.js 801 Bytes
var Slide = require('./yohoui/YH.slide');
var $ = require('yoho.jquery');

var $contain = $('.slide-list', '.slide-accordion');
var $item = $contain.find('li');

var $width = 650;
var slide;

function switchfun(to) {
    $item.each(function(index) {
        if (index <= to) {
            $(this).stop().animate({
                left: index * (120 + 5)
            });
        } else {
            $(this).stop().animate({
                left: (to) * (120 + 5) + $width + (120 + 5) * (index - to - 1)
            });
        }
    });
}

switchfun(0);

slide = new Slide({
    length: 5,
    loop: false,
    auto: false,
    timeout: 2,
    index: 3
});

slide.on('change', function(data) {
    switchfun(data.to);
});

$item.mouseover(function() {
    slide.go($(this).index());
});

slide.init();