'How to add Owl-Carousel-2 completeness percent(%) status bar(not progressBar)?
First of all this is not about "progressBar", I need a completeness percent(%) status bar for owlCarousel-2, if there is any confusion in my question and description then please check the images below.
I have just created a pen, please check the link - https://codepen.io/tsarkar/pen/NmpGmV
(source: testyourprojects.biz)
I just have complete with "Total Item count" and "Current item count", but can't implement the status(%) bar like the images I have posted. Please check my code below.
$(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)
}
});
Solution 1:[1]
Finally I have got the solutions for this, please check the code below and also the pen.
$(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 + "%")
}
});
You can check my solution here https://codepen.io/tsarkar/pen/NmpGmV
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | jqueryHub |