Fahad Khan
Fahad Khan

Reputation: 1635

How to start with a specific index - basic jquery slider

I am using a slider Basic Jquery Slider

I want to start with 2nd index or sometimes 3rd index.

How can I achieve this? I tried options below, but did not work:

$('#banner-slides').bjqs({
   animtype     : 'slide',
   currentslide : 2,
   currentindex : 1
});

Upvotes: 0

Views: 391

Answers (1)

Cerlin
Cerlin

Reputation: 6722

    this.goto = function(position){ // this keyword is added here
        state.animating = false;
        if(settings.animtype === "slide")
            position = position + 1;
        go(false,position);
    }
    init();
    return this; // newly added code

You can add the above script to the bjqs-1.3.js file and initialize the slider like

var bannerslides = $('#banner-slides').bjqs({
   animtype     : 'slide'
});

then use bannerslides.goto(1) to go to first slide

you can create multiple sliders like

var bannerslides1 = $('#banner-slides1').bjqs({
   animtype     : 'slide'
});


var bannerslides2 = $('#banner-slides2').bjqs({
   animtype     : 'slide'
});

and use it like bannerslides1.goto(1) to go to first slide of bannerslides1 slider and bannerslides2.goto(1) to go to first slide of bannerslides2 slider

I hope you can calculate the slidenumbers

NOTE : I haven't tested fully.

UPDATE

I have added one more condition to make it work if the animation was fade

UPDATE

Find the new code and let me know if it works

Upvotes: 2

Related Questions