I have some Jquery that applies to a loading bar but I'd like the loading bar not to fill until its within view, is there anyway to do this? Th Jquery that controls the loading bar is below, if you need the CSS, HTML, or a jsfiddle example of the current loading bar let me know. Any help is greatly appreciated!
$('.bar-percentage[data-percentage]').each(function () {
var progress = $(this);
var percentage = Math.ceil($(this).attr('data-percentage'));
$({countNum: 0}).animate({countNum: percentage}, {
duration: 2000,
easing:'swing',
step: function() {
// What todo on every count
var pct = '';
if(percentage == 0){
pct = Math.floor(this.countNum) + '%';
}else{
pct = Math.floor(this.countNum+1) + '%';
}
progress.text(pct) && progress.siblings().children().css('width',pct);
}
});
});