Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

counter.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. "use strict";
  2. $(document).ready(function(){
  3. (function($) {
  4. /* ======== animatePieCharts ================= */
  5. function animatePieCharts() {
  6. if(typeof $.fn.easyPieChart != 'undefined'){
  7. $(".chart").each(function() {
  8. var $t = $(this);
  9. var n = $t.parent().width();
  10. var r = $t.attr("data-barSize");
  11. if (n < r) {
  12. r = n;
  13. }
  14. $t.easyPieChart({
  15. animate: 1300,
  16. lineCap: "square",
  17. lineWidth: $t.attr("data-lineWidth"),
  18. size: r,
  19. barColor: $t.attr("data-barColor"),
  20. trackColor: $t.attr("data-trackColor"),
  21. scaleColor: "transparent",
  22. onStep: function(from, to, percent) {
  23. $(this.el).find('.chart-percent span').text(Math.round(percent));
  24. }
  25. });
  26. });
  27. }
  28. }
  29. /* ======= When document is ready, do ==================== */
  30. $(document).ready(function() {
  31. var chart_offset = $('.chart').offset().top,
  32. chart_outer_height = $('.chart').outerHeight(),
  33. chart_height = $(window).height(),
  34. wS = $(this).scrollTop();
  35. if (wS > (chart_offset+chart_outer_height-chart_height)){
  36. animatePieCharts();
  37. }
  38. });
  39. /* ==========================================================================
  40. When the window is scrolled, do
  41. ========================================================================== */
  42. $(window).on('scroll',function() {
  43. var chart_offset = $('.chart').offset().top,
  44. chart_outer_height = $('.chart').outerHeight(),
  45. chart_height = $(window).height(),
  46. wS = $(this).scrollTop();
  47. if (wS > (chart_offset+chart_outer_height-chart_height)){
  48. animatePieCharts();
  49. }
  50. });
  51. })(window.jQuery);
  52. });