0

Ok, so i've got this code, it almost works i'm just stuck on the last bit!

$('.button').click(function() {
var id = this.id;
$('#slide'+id+'').each(function() {
    if ($(this).offset().left < 0) {

    } else {
        $('.current').animate({ left: '-200%', }, 1500 );
        $('.current').removeClass("current").addClass("previous");

        $(this).animate({ left: '-100%', }, 1500 );
        $(this).addClass("current");
        $('.previous').removeAttr('style');

    }
});
});

As you can see the current slide moves left, new slide moves in from right. Current is then reclassed previous, and then new slide is then classed current.

However the new previous slide still has in-line style left:-100% applied to it. I need to remove this style!??

Basically i need the slides to always go from right to left, even if it has been visited already! PLEASE SOMEONE HELP!!??

http://jsfiddle.net/ngpsk/

********SOLVED IT MYSELF*******

$('.button').click(function() {
var id = this.id;
$('#slide'+id+'').each(function() {
    if ($(this).offset().left < 0) {

    } else {
        $('.current').animate({ left: '-100%', }, 2000, function()
                {
                    $(this).removeAttr('style').removeClass("current");
                    $('#slide1').css("left", "100%");
                }
            );

        $(this).animate({ left: '0%', }, 2000 );
        $(this).addClass("current");
    }
});

});

SEEMS TO WORK AT LEAST!

4

1 に答える 1

0

アニメーションが完了したらクラスを削除します。例については、次を参照してください: jQuery イベントの順序とアニメーションが完了するまで待機

于 2013-05-23T11:27:32.417 に答える