javascript - Progress bar to load same speed as div's -


on progress bar trying make detects div loading speed.

what trying achieve if div fast loading go 100 % quick. progress bar should load fast div loads.

question: how can make progress bar load speed div loads at.

view codepen example click view

java script

settimeout(function(){  $('.progress .progress-bar').each(function() {  var me = $(this); var perc = me.attr("data-percentage");  var current_perc = 0;  var progress = setinterval(function() { if (current_perc>=perc) {     clearinterval(progress); } else {     current_perc +=1;     me.css('width', (current_perc) + '%'); }  me.text('page loading ' + (current_perc) + ' %');  }, 50);  });  },300); 

html

<div class="container big-space">     <div class="progress progress-striped active">         <div class="progress-bar" style="width: 0%;" data-percentage="100"></div>     </div> </div>  <div class="container big-space"> <div class="well"> <h4>sample div</h4> </div> </div> 

just remove transition , animation classes css:

.progress-bar.active, .progress.active .progress-bar {     -webkit-animation: none;     animation: none; } .progress-bar {     -webkit-transition : none;     transition : none; } 

you make animation more smooth:

.progress-bar {     transition: width .05s ease; } 

anyway notice, 0.05s equals interval.

see adapted example here: codepen example


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -