I have a project where I need to adjust the time interval for each individual slide in my carousel in real-time using basic form inputs.
<input type="number" id="slide1">
I found a helpful link on how to achieve this: individual data intervals bootstrap carousel 4
$.fn.carousel.Constructor.prototype.cycle = function (event)
{
if (!event)
this._isPaused = false;
if (this._interval)
{
clearInterval(this._interval);
this._interval = null;
}
if (this._config.interval && !this._isPaused)
{
var item = $('.carousel-item-next');
var newInterval = item.data('interval') || this._config.interval;
this._interval = setInterval(
(document.visibilityState ? this.nextWhenVisible : this.next).bind(this),
newInterval);
}
};
My carousel is now working with different intervals for each slide, which is great.
However, I am facing an issue with changing intervals after the carousel has been initialized. Any suggestions or solutions would be greatly appreciated.
Thank you!
EDIT
Update: The problem was due to my outdated version of Bootstrap...