Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange bootstrap progress bar behavior in Firefox

I've got a simple animated bootstrap progress bar in my app that's behaving oddly in Firefox only.

HTML:

<div id="render-progress" class="progress progress-striped active" >
  <div class="bar" style="width: 25%; height:100%;background-color: #CCCCCC;"></div>
</div>

JS:

$('#render-progress .bar').animate({width:'50%'}, 2000);

In Chrome it goes from 25% to 50% like it should, but in Firefox it goes from 25% to 75% to 50%.

It's driving me nuts, I can't figure out why it's acting like that.

SEE FIDDLE: http://jsfiddle.net/dv4Hd/12/

like image 616
Yarin Avatar asked Mar 04 '14 02:03

Yarin


2 Answers

This appears to be a jQuery bug regarding animating using percentages.

It is referenced here but marked as fixed for 1.7 - it reappears in 1.8.3 as changing the jQuery version to 1.6.4 or 1.7.2 in your fiddle will make it work as expected.

Additionally, converting to pixels works as expected: http://jsfiddle.net/dv4Hd/24/

// Must include code when linking to fiddle
var $progressBar = $('#render-progress .bar');
var percentIncrease = 0.50;
var parentWidth = $('.progress').width();
var increasePx = parentWidth * percentIncrease;
$progressBar.animate({width:increasePx}, 2000)

I'll search the queue to make sure a report isn't already active, and submit one this week if not.

like image 190
Chris Rockwell Avatar answered Oct 20 '22 20:10

Chris Rockwell


$('.bar').animate({width:'50%'});

This seems to work properly But the time property is gone :/ !

But you can still get it up with transition delay :)

Note : I am not sure, but I feel like if the time value in the animate function and the transition-duration is set to same values

$('.bar').animate({width:'50%'},2000);

and in css

transition-duration:2s

The animate seems to work properly :)

like image 21
Magesh Kumaar Avatar answered Oct 20 '22 21:10

Magesh Kumaar