Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed flickering on centered text on multiple trigger

  • Loading branch information...
commit a2094f8b4e13894b2ebc96bef84e4fe343eafdf8 1 parent 35428eb
@minddust authored
Showing with 9 additions and 10 deletions.
  1. +7 −8 bootstrap-progressbar.js
  2. +2 −2 bootstrap-progressbar.min.js
View
15 bootstrap-progressbar.js
@@ -1,5 +1,5 @@
/* ========================================================
- * bootstrap-progressbar v0.4.5
+ * bootstrap-progressbar v0.4.6
* ========================================================
* Copyright 2012 minddust.com
*
@@ -28,6 +28,8 @@
transition: function() {
var $this = this.element,
$parent = $this.parent(),
+ $back = this.back,
+ $front = this.front,
options = this.options,
percentage = $this.attr('data-percentage'),
amount_part = $this.attr('data-amount-part'),
@@ -54,7 +56,7 @@
}
}
- if (options.display_text === $.fn.progressbar.display_text.center) {
+ if (options.display_text === $.fn.progressbar.display_text.center && !$front && !$back) {
$parent.css('position', 'relative');
$this.css({
'position': 'absolute',
@@ -65,13 +67,10 @@
'border-radius': options.border_radius
});
- $parent.find('.progressbar-front-text').remove();
- $parent.find('.progressbar-back-text').remove();
-
$parent.prepend('<span class="progressbar-back-text" style="position:absolute;width:100%;text-align:center"></span>');
$this.prepend('<span class="progressbar-front-text" style="display:block;text-align:center"></span>');
- var $back = $parent.find('.progressbar-back-text'),
- $front = $parent.find('.progressbar-front-text');
+ this.back = $back = $parent.find('.progressbar-back-text'),
+ this.front = $front = $parent.find('.progressbar-front-text');
$front.css('width', $parent.css('width'));
$(window).resize(function() {
$front.css('width', $parent.css('width'));
@@ -107,8 +106,8 @@
$this.text(text);
}
else if (options.display_text === $.fn.progressbar.display_text.center) {
- $front.text(text);
$back.text(text);
+ $front.text(text);
}
}
View
4 bootstrap-progressbar.min.js
@@ -1,2 +1,2 @@
-/* bootstrap-progressbar v0.4.5 | Copyright 2012 minddust.com | http://www.apache.org/licenses/LICENSE-2.0 */
-(function(b){var e=function(c,d){this.element=b(c);this.options=b.extend({},b.fn.progressbar.defaults,d)};e.prototype={constructor:e,transition:function(){var c=this.element,d=c.parent(),a=this.options,f=c.attr("data-percentage"),e=c.attr("data-amount-part"),i=c.attr("data-amount-total"),n,o,g;n=a.update&&"function"===typeof a.update?a.update:b.fn.progressbar.defaults.update;o=a.done&&"function"===typeof a.done?a.done:b.fn.progressbar.defaults.done;g=a.fail&&"function"===typeof a.fail?a.fail:b.fn.progressbar.defaults.fail;if(a.use_percentage&&!f)g("bootstrap-progressbar: you can't use percentage without data-percentage being set");else{if(!a.use_percentage){if(!e&&!i){g("bootstrap-progressbar: you can't use values without data-amount-part and data-amount-total being set");return}f=Math.round(100*e/i)}if(a.display_text===b.fn.progressbar.display_text.center){d.css("position","relative");c.css({position:"absolute","float":"left",overflow:"hidden","-webkit-border-radius":a.border_radius,"-moz-border-radius":a.border_radius,"border-radius":a.border_radius});d.find(".progressbar-front-text").remove();d.find(".progressbar-back-text").remove();d.prepend('<span class="progressbar-back-text" style="position:absolute;width:100%;text-align:center"></span>');c.prepend('<span class="progressbar-front-text" style="display:block;text-align:center"></span>');var p=d.find(".progressbar-back-text"),k=d.find(".progressbar-front-text");k.css("width",d.css("width"));b(window).resize(function(){k.css("width",d.css("width"))})}setTimeout(function(){c.css("width",f+"%");var h,g,l,m,j,q=setInterval(function(){l=c.width();m=d.width();h=Math.round(100*l/m);g=Math.round(l/m*i);h>=f&&(h=f,g=e,o(),clearInterval(q));a.display_text!==b.fn.progressbar.display_text.none&&(j=a.use_percentage?h+"%":g+" / "+i,a.display_text===b.fn.progressbar.display_text.filled?c.text(j):a.display_text===b.fn.progressbar.display_text.center&&(k.text(j),p.text(j)));n(h)},a.refresh_speed)},a.transition_delay)}}};b.fn.progressbar=function(c){return this.each(function(){var d=b(this),a=d.data("progressbar"),f="object"===typeof c&&c;a||d.data("progressbar",a=new e(this,f));if("string"===typeof c)a[c]();a.transition()})};b.fn.progressbar.display_text={none:0,filled:1,center:2};b.fn.progressbar.defaults={transition_delay:300,refresh_speed:50,display_text:b.fn.progressbar.display_text.none,use_percentage:!0,border_radius:"4px",update:b.noop,done:b.noop,fail:b.noop};b.fn.progressbar.Constructor=e})(window.jQuery);
+/* bootstrap-progressbar v0.4.6 | Copyright 2012 minddust.com | http://www.apache.org/licenses/LICENSE-2.0 */
+(function(b){var e=function(c,d){this.element=b(c);this.options=b.extend({},b.fn.progressbar.defaults,d)};e.prototype={constructor:e,transition:function(){var c=this.element,d=c.parent(),f=this.back,g=this.front,a=this.options,i=c.attr("data-percentage"),e=c.attr("data-amount-part"),k=c.attr("data-amount-total"),o,p,h;o=a.update&&"function"===typeof a.update?a.update:b.fn.progressbar.defaults.update;p=a.done&&"function"===typeof a.done?a.done:b.fn.progressbar.defaults.done;h=a.fail&&"function"===typeof a.fail?a.fail:b.fn.progressbar.defaults.fail;if(a.use_percentage&&!i)h("bootstrap-progressbar: you can't use percentage without data-percentage being set");else{if(!a.use_percentage){if(!e&&!k){h("bootstrap-progressbar: you can't use values without data-amount-part and data-amount-total being set");return}i=Math.round(100*e/k)}a.display_text===b.fn.progressbar.display_text.center&&(!g&&!f)&&(d.css("position","relative"),c.css({position:"absolute","float":"left",overflow:"hidden","-webkit-border-radius":a.border_radius,"-moz-border-radius":a.border_radius,"border-radius":a.border_radius}),d.prepend('<span class="progressbar-back-text" style="position:absolute;width:100%;text-align:center"></span>'),c.prepend('<span class="progressbar-front-text" style="display:block;text-align:center"></span>'),this.back=f=d.find(".progressbar-back-text"),this.front=g=d.find(".progressbar-front-text"),g.css("width",d.css("width")),b(window).resize(function(){g.css("width",d.css("width"))}));setTimeout(function(){c.css("width",i+"%");var j,h,m,n,l,q=setInterval(function(){m=c.width();n=d.width();j=Math.round(100*m/n);h=Math.round(m/n*k);if(j>=i){j=i;h=e;p();clearInterval(q)}if(a.display_text!==b.fn.progressbar.display_text.none){l=a.use_percentage?j+"%":h+" / "+k;if(a.display_text===b.fn.progressbar.display_text.filled)c.text(l);else if(a.display_text===b.fn.progressbar.display_text.center){f.text(l);g.text(l)}}o(j)},a.refresh_speed)},a.transition_delay)}}};b.fn.progressbar=function(c){return this.each(function(){var d=b(this),f=d.data("progressbar"),g="object"===typeof c&&c;f||d.data("progressbar",f=new e(this,g));if("string"===typeof c)f[c]();f.transition()})};b.fn.progressbar.display_text={none:0,filled:1,center:2};b.fn.progressbar.defaults={transition_delay:300,refresh_speed:50,display_text:b.fn.progressbar.display_text.none,use_percentage:!0,border_radius:"4px",update:b.noop,done:b.noop,fail:b.noop};b.fn.progressbar.Constructor=e})(window.jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.