I have used mcustomscrollbar in my slider area.
Please refer the url horizontal scroll example url here
I used the horizontal scroll section content x
Below is the code I have used
$(".selector").mCustomScrollbar({
axis:"x",
autoHideScrollbar:true,
alwaysShowScrollbar:0,
contentTouchScroll:true,
mouseWheel: false,
advanced:{autoExpandHorizontalScroll:true},
callbacks:{
onScroll:function(){
alert(this.mcs.leftPct); /// This is the scrol percentage
}
}
});
Here it is working fine. My task is in the call back area I have got the scroll percentage. By using this how to get the current element no. i.e Initially the scroll percentage is 0 and the element is 0th andd 1st element is viewed. After I drag the scroll bar it moved to some position. At that time which element is in view port slider area. While scroll I want to get the current element, where the scroll bar is.
Please help me to get this. If the scroll bar is below the 3rd element, I want to retrieve the element number.
To get the element no, I used the following:
var tot_item_count = 12;
var elm_no = Math.round((tot_item_count*this.mcs.leftPct)/100);
But it gives wrong result
Refer screen shots:
Here the scroll for all images
Here the scroll is near the 3rd element
Here the scroll is near the 5rd element