The following code controls a function for sliding various items across a bar. It is using a plugin called JQuery animate enhanced that uses CSS3 where possible on supporting browsers.
没有CSS3,这一职能就完全运作。 然而,一旦选定了所有表格,便会与CSS3合作。
http://jsfiddle.net/cqBZz/3/“rel=“nofollow”http://jsfiddle.net/cqBZz/3/
守则:
$(document).ready(function () {
var bounceholder = 0;
var delayact = 0;
$( .bouncetabs a ).click(function () {
$( .bouncetabs a ).removeClass( active );
$(this).addClass( active );
if ($(this).index( .bouncetabs a ) < bounceholder) {
var backwards = 1
} else {
var backwards = 0
}
bounceholder = $(this).index( .bouncetabs a );
var bounceoffset = 0;
if ($( .bounceholder ul:eq( + bounceholder + ) li ).length == 6) {
var bounceoffset = 0;
} else if ($( .bounceholder ul:eq( + bounceholder + ) li ).length == 5) {
var bounceoffset = 72;
} else if ($( .bounceholder ul:eq( + bounceholder + ) li ).length == 4) {
var bounceoffset = 144;
} else if ($( .bounceholder ul:eq( + bounceholder + ) li ).length == 3) {
var bounceoffset = 216;
} else if ($( .bounceholder ul:eq( + bounceholder + ) li ).length == 2) {
var bounceoffset = 288;
}
$( .bounceholder ul:eq( + bounceholder + ) ).prevAll().each(function () {
$( li , this).each(function () {
$(this).delay(150).animate({
left: -200,
top: 0,
leaveTransforms: true
}, {
duration: 400,
queue: true
});
});
});
$( .bounceholder ul:eq( + bounceholder + ) ).nextAll().each(function () {
$( li , this).each(function () {
$(this).delay(150).animate({
left: +1000,
top: 0,
leaveTransforms: true
}, 600);
});
});
if (backwards == 1) {
bounceoffset = 800 - bounceoffset;
$($( .bounceholder ul:eq( + bounceholder + ) li ).get().reverse()).each(function (i) {
delay = (i + 1) * 100;
$(this).delay(delay).animate({
left: +bounceoffset,
top: 0,
opacity: 0.6,
leaveTransforms: true
}, {
duration: 400,
queue: true
});
bounceoffset -= 160;
});
} else {
$( .bounceholder ul:eq( + bounceholder + ) li ).each(function (i) {
delay = (i + 1) * (100 * delayact);
$(this).delay(delay).animate({
left: +bounceoffset,
top: 0,
opacity: 0.6,
leaveTransforms: true
}, {
duration: 400,
queue: true
});
bounceoffset += 160;
});
}
delayact = 1;
return false
});
});