【发布时间】:2019-11-06 05:04:05
【问题描述】:
对于一个项目,我想(实时)修改轮播中的每个幻灯片间隔(单独),并使用一些基本的表单输入。
<input type="number" id="slide1">
我点击这个链接: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);
}
};
在我不同的时间间隔内一切正常。
但是现在...轮播初始化后无法更改间隔。
有什么想法吗?
提前谢谢你。
编辑
问题出在我的旧版 Bootstrap...
【问题讨论】:
-
初始化后更改轮播时,需要将当前轮播处理掉,并使用新选项https://getbootstrap.com/docs/4.3/components/carousel/#carouseldispose重新初始化轮播
-
谢谢,但我不太明白该怎么做。你有什么例子吗?
标签: javascript twitter-bootstrap bootstrap-4