Skip to content

Commit

Permalink
Fix to update value dynamically. Resolves #42
Browse files Browse the repository at this point in the history
  • Loading branch information
teobais committed Nov 2, 2017
1 parent b95df1c commit ae996ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/js/percircle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2>Color variants</h2>
</div>
</div>
<!-- /some colors -->

<h2>Custom text</h2>
<!-- custom text -->
<div class="clearfix">
Expand All @@ -62,6 +62,14 @@ <h2>Custom text</h2>
</div>
<!-- /custom text -->

<h2>Update value dynamically</h2>
<!-- update value dynamically-->
<div class="clearfix">
<div id="redBecomesBlue" class="red big"></div>
</div>
<pre> <a href="javascript:void(0);" id="changeCircle">Fill Circle to 95.5</a><br><br></pre>
<!-- /update value dynamically -->

<h2>Dark theme</h2>
<!-- .dark-area -->
<div class="dark-area clearfix">
Expand Down Expand Up @@ -130,6 +138,23 @@ <h2>Custom options</h2>
percent: 64.5
});
});

$(document).ready(function(){
$("#redBecomesBlue").percircle({percent: 25,text: "25"});
$('#changeCircle').click(function(e){
e.preventDefault();
changeCircle();
});
});

function changeCircle(){
$("#redBecomesBlue").percircle({text:''});
$("#redBecomesBlue").percircle({
text: "",
percent: 95.5,
progressBarColor: "#1252c0"
});
}
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion src/js/percircle.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
if (percent > 50) percircle.addClass('gt50');
var text = percircle.attr('data-text') || options.text || percent + '%';

$('<span>'+text+'</span>').appendTo(percircle);
percircle.html('<span>'+text+'</span>');

// add divs for structure
$('<div class="slice"><div class="bar" '+progressBarColor+'></div><div class="fill" '+progressBarColor+'></div></div>').appendTo(percircle);
if (percent > 50)
Expand Down

0 comments on commit ae996ac

Please sign in to comment.