```javascript
{
- // Chart object
- chart: Chart,
+ // Chart object
+ chart: Chart,
- // Number of animations still in progress
- currentStep: number,
+ // Number of animations still in progress
+ currentStep: number,
- // Total number of animations at the start of current animation
- numSteps: number,
+ // `true` for the initial animation of the chart
+ initial: boolean,
+
+ // Total number of animations at the start of current animation
+ numSteps: number,
}
```
# Animation Progress Bar
+## Initial animation
+
+<progress id="initialProgress" max="1" value="0" style="width: 100%"></progress>
+
+## Other animations
+
<progress id="animationProgress" max="1" value="0" style="width: 100%"></progress>
```js chart-editor
// </block:actions>
// <block:setup:1>
+const initProgress = document.getElementById('initialProgress');
const progress = document.getElementById('animationProgress');
const DATA_COUNT = 7;
options: {
animation: {
duration: 2000,
- onProgress: function(animation) {
- progress.value = animation.currentStep / animation.numSteps;
+ onProgress: function(context) {
+ if (context.initial) {
+ initProgress.value = context.currentStep / context.numSteps;
+ } else {
+ progress.value = context.currentStep / context.numSteps;
+ }
},
- onComplete: function() {
- //
+ onComplete: function(context) {
+ if (context.initial) {
+ console.log('Initial animation finished');
+ } else {
+ console.log('animation finished');
+ }
}
},
interaction: {
module.exports = {
actions: actions,
config: config,
+ output: 'console.log output is displayed here'
};
```
callbacks.forEach(fn => fn({
chart,
+ initial: anims.initial,
numSteps,
currentStep: Math.min(date - anims.start, numSteps)
}));
if (!items.length) {
anims.running = false;
me._notify(chart, anims, date, 'complete');
+ anims.initial = false;
}
remaining += items.length;
if (!anims) {
anims = {
running: false,
+ initial: true,
items: [],
listeners: {
complete: [],