Click here to Skip to main content
15,844,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi
I write a slider,when I click on prev and next buttons the time sliders are hide takes too long. i want to see next slide immediately.
would some body please help me?
you can check in plugin in below adress:

[^]

here is my.js code:
C#
$(document).ready(function () {
    {
        $(".Prev").css({
            "position": "fixed",
            "top": "203px",
            "left": "74px",
            "width": "65px",
          "height": "65px",
            "background-image": "url(/HoshITC/images/prev.png)"
        });
        $(".Next").css({
            "position": "absolute",
            "left": "867px",
            "top": "200px",
            "width": "65px",
            "height": "65px",
            "background-image": "url(/HoshITC/images/next.png)"
        });

    }
    var counter = 0;
    var slideCount = $(".slides>li").length;
    var sliderTimer;

    $(".slides>li").each(function () {
        //debugger;
        counter += 1;
        $(this).attr("id", "slide" + counter);
    });


    function hideAllSlides() {
    $(".slides>li").css("display", 'none');
    }

    function resetTimer() {
        clearInterval(sliderTimer);
        sliderTimer = setInterval(function () {
            counter += 1;
            if (counter > slideCount)
                counter = 1;
            hideAllSlides();
            $(".slides #slide" + counter).fadeIn();
            }, 2000);

    }
    $("#Next").click(function () {
        debugger;
        counter += 1;
        if (counter > slideCount)
            counter = 1;
        hideAllSlides();
        $(".slides>li" + counter).fadeIn(10);

    });

    $("#Prev").click(function () {
        counter -= 1;
        if (counter < 1)
            counter = slideCount;
        hideAllSlides();
        $(".slides>li" + counter).fadeIn(10);

        //resetTimer();

    });

    hideAllSlides();
    counter = 1;
    $(".slides li:eq(1)").show();
    resetTimer();

});
Posted
Comments
Shivaram_i 9-Jun-15 4:45am    
hideAllSlides();
$(".slides #slide" + counter).fadeIn();
}, 2000);

in that line reduce the time.. i.e remove 2000 and put some 100,200 like that
behish 9-Jun-15 4:56am    
I did,but it's my slider timer,if I reduce it to 100,200 sliders are shown so fast.
my problem is when I click on next,preview buttons it takes some seconds to show next slide,and I don't want that!!!
Rashmi Sutar 10-Jun-15 8:39am    
Hi,

I think you can use add class and remove class methods in controls.click function
and set the time variable and use it as below.

var TIME=500;
controls.removeClass('active');
controls.eq(current).addClass('active');

slides.eq(current).stop().animate({
left: '-994px'
}, TIME, function () {
$(this).removeClass('active');
inProgress = false;
startTimer()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900