Skip to content

Commit c37ee63

Browse files
author
Alexander Bashev
committed
Added ability to set animation delay
1 parent 76b3ec1 commit c37ee63

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ you can set the options easily as data attributes for Example: data-dimension="2
5959
| animationstep | Will set the animation step, use 0 to disable animation, 0.5 to slow down, 2 to speed up, etc | interger | 1 |
6060
| startdegree | is the degree to start animate fgcolor | interger | 0 |
6161
| bordersize | set the width of the border | interger | 10 |
62+
| delay | set animation delay | interger | 0 |
6263

6364

6465

js/jquery.circliful.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
iconcolor: '#999',
2020
border: 'default',
2121
complete: null,
22-
bordersize: 10
22+
bordersize: 10,
23+
delay: 0
2324
}, options);
2425

2526
return this.each(function () {
2627

27-
var customSettings = ["fgcolor", "bgcolor", "fill", "width", "dimension", "fontsize", "animationstep", "endPercent", "icon", "iconcolor", "iconsize", "border", "startdegree", "bordersize"];
28+
var customSettings = ["fgcolor", "bgcolor", "fill", "width", "dimension", "fontsize", "animationstep", "endPercent", "icon", "iconcolor", "iconsize", "border", "startdegree", "bordersize", "delay"];
2829

2930
var customSettingsObj = {};
3031
var icon = '';
@@ -130,6 +131,7 @@
130131
var type = '';
131132
var fireCallback = true;
132133
var additionalAngelPI = (customSettingsObj.startdegree / 180) * Math.PI;
134+
var animationDelay = customSettingsObj.delay;
133135

134136
if ($(this).data('type') != undefined) {
135137
type = $(this).data('type');
@@ -141,7 +143,7 @@
141143
quart = Math.PI / 0.996;
142144
}
143145
}
144-
146+
145147
if ($(this).data('type') != undefined) {
146148
type = $(this).data('type');
147149

@@ -183,8 +185,8 @@
183185
.appendTo(obj)
184186
.addClass('circle-info-half')
185187
.css(
186-
'line-height', (customSettingsObj.dimension * factor) + 'px'
187-
)
188+
'line-height', (customSettingsObj.dimension * factor) + 'px'
189+
)
188190
.text(info);
189191
}
190192

@@ -207,11 +209,9 @@
207209
}
208210

209211
/**
210-
* animate foreground circle
211-
* @param current
212+
* draw background circle
212213
*/
213-
function animate(current) {
214-
214+
function bgrCircle () {
215215
context.clearRect(0, 0, canvas.width, canvas.height);
216216

217217
context.beginPath();
@@ -227,6 +227,15 @@
227227
context.fill();
228228
}
229229

230+
}
231+
232+
/**
233+
* animate foreground circle
234+
* @param current
235+
*/
236+
function animate(current) {
237+
238+
230239
context.beginPath();
231240
context.arc(x, y, radius, -(quart) + additionalAngelPI, ((circ) * current) - quart + additionalAngelPI, false);
232241

@@ -255,8 +264,13 @@
255264
}
256265
}
257266

258-
animate(curPerc / 100);
267+
bgrCircle ();
268+
269+
setTimeout(function () {
270+
animate(curPerc / 100);
271+
}, animationDelay);
259272

273+
console.log(animationDelay);
260274
});
261275
};
262-
}(jQuery));
276+
}(jQuery));

js/jquery.circliful.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)