Skip to content

Commit ef54582

Browse files
author
Patric Gutersohn
committed
fixed animation for multiple bars
1 parent 192e025 commit ef54582

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

js/jquery.circliful.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,16 @@
227227
if (index > 0) {
228228
circleRadius = circleRadius + 62.5;
229229
currentCalculateFill = (circleRadius / 100 * percent);
230-
231-
animateCircle(currentCircle, currentCalculateFill);
232230
}
231+
232+
animateCircle(currentCircle, currentCalculateFill, circleRadius, percent);
233233
}
234234
} else {
235-
animateCircle(currentCircle, currentCalculateFill);
235+
animateCircle(currentCircle, currentCalculateFill, 360, percent);
236236
}
237237
}
238238

239-
function animateCircle(currentCircle, currentCalculateFill) {
239+
function animateCircle(currentCircle, currentCalculateFill, circleRadius, percent) {
240240
var timer = window.setInterval(function () {
241241
if ((angle) >= currentCalculateFill) {
242242
window.clearInterval(timer);
@@ -249,12 +249,12 @@
249249
summary += oneStep;
250250
}
251251
if (settings.halfCircle) {
252-
if (angle * 2 / 3.6 >= percent && last === 1) {
253-
angle = (3.6 * percent) / 2
252+
if (angle * 2 / (circleRadius / 100) >= percent && last === 1) {
253+
angle = ((circleRadius / 100) * percent) / 2
254254
}
255255
} else {
256-
if (angle / 3.6 >= percent && last === 1) {
257-
angle = 3.6 * percent;
256+
if (angle / (circleRadius / 100) >= percent && last === 1) {
257+
angle = (circleRadius / 100) * percent;
258258
}
259259
}
260260

@@ -264,9 +264,9 @@
264264

265265
if (settings.replacePercentageByText === null) {
266266
if (settings.halfCircle) {
267-
text = parseFloat((100 * angle / 360) * 2);
267+
text = parseFloat((100 * angle / circleRadius) * 2);
268268
} else {
269-
text = parseFloat((100 * angle / 360));
269+
text = parseFloat((100 * angle / circleRadius));
270270
}
271271
text = text.toFixed(settings.decimals);
272272
if (!settings.alwaysDecimals && (percent === 0 || (percent > 1 && last !== 1))) {
@@ -305,7 +305,7 @@
305305
if (settings.halfCircle) {
306306
key /= 2
307307
}
308-
if (angle >= key * 3.6) {
308+
if (angle >= key * (circleRadius / 100)) {
309309
currentCircle.css({
310310
stroke: color,
311311
transition: 'stroke 0.1s linear'

0 commit comments

Comments
 (0)