Answer the question
In order to leave comments, you need to log in
How to replace an array with a value and reinitialize a function?
Hello, it's hard with the theory, so I can't figure out what to do in this case:
Is there a function (or method?) - .vegas();
It contains an array of elements. interested in - slides:
In general, when you click on some buttons, change the array of photos and reinitialize the function to immediately work.
To be honest, I don't know which way to go.
$("#example, body").vegas({
slides: [
{src: "./img/bg/4.jpg"},
{src: "./img/bg/5.jpg"},
{src: "./img/bg/6.jpg"},
{src: "./img/bg/7.jpg"},
{src: "./img/bg/8.jpg"},
{src: "./img/bg/9.jpg"}
],
overlay: true,
transition: [ 'fade', 'fade2' ],
});
Answer the question
In order to leave comments, you need to log in
I guess based on the sources ( https://github.com/jaysalvat/vegas/blob/master/src... something like this:
//убиваем текущий инстанс
$("#example, body").vegas('destroy');
//вызываем новый, уже с другими фотками
$("#example, body").vegas({
slides: [
{src: "./img/bg/4.jpg"},
{src: "./img/bg/5.jpg"},
{src: "./img/bg/6.jpg"},
{src: "./img/bg/7.jpg"},
{src: "./img/bg/8.jpg"},
{src: "./img/bg/9.jpg"}
],
overlay: true,
transition: [ 'fade', 'fade2' ],
});
var slides = [
{src: "./img/bg/4.jpg"},
{src: "./img/bg/5.jpg"},
{src: "./img/bg/6.jpg"},
{src: "./img/bg/7.jpg"},
{src: "./img/bg/8.jpg"},
{src: "./img/bg/9.jpg"}
];
$("#example, body").vegas('options', 'slides', slides)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question