首先,这与“ progressBar”无关,我需要owlCarousel-2的完整性百分比(%)状态栏,如果我的问题和描述有任何混淆,请检查以下图像。
我刚创建了一支笔,请检查链接-https://codepen.io/tsarkar/pen/NmpGmV
我仅完成了“总项目数”和“当前项目数”,但是无法实现状态栏(%),就像我发布的图像一样。请在下面检查我的代码。
$(function(){
var owl = $('.ivySlide');
$('.ivySlide').owlCarousel({
smartSpeed: 500,
items: 1,
margin:0,
nav:true,
dots:false,
onInitialized:counter,
onTranslated:counter
});
function counter(event) {
var element = event.target;
var items = event.item.count;
var item = event.item.index + 1;
var sldtxt = $('.active .ivySlideTxt').html();
$('#counter').html(item+" / "+items)
}
});
答案 0 :(得分:0)
最后我已经找到解决方案,请检查下面的代码以及笔。
$(function(){
$('.ivySlide').owlCarousel({
smartSpeed: 500,
items: 1,
margin:0,
nav:true,
dots:false,
onInitialized:counter,
onTranslated:counter
});
function counter(event) {
var element = event.target;
var items = event.item.count;
var item = event.item.index + 1;
var sldtxt = $('.active .ivySlideTxt').html();
var sldWidth = 100;
var sldPercent = sldWidth * item / items;
$('#counter').html(item+" / "+items)
$('.slTxt').html(sldtxt);
$('.slideState span').css("width", sldPercent + "%");
$('.slideState span').html(sldPercent + "%")
}
});
处查看我的解决方案