source: node_modules/recharts/lib/animation/AnimationManager.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.8 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.createAnimateManager = createAnimateManager;
7/**
8 * Represents a single item in the ReactSmoothQueue.
9 * The item can be:
10 * - A number representing a delay in milliseconds.
11 * - An object representing a style change
12 * - A StartAnimationFunction that starts eased transition and calls different render
13 * because of course in Recharts we have to have three ways to do everything
14 * - An arbitrary function to be executed
15 */
16
17function createAnimateManager(timeoutController) {
18 var currStyle;
19 var handleChange = () => null;
20 var shouldStop = false;
21 var cancelTimeout = null;
22 var setStyle = _style => {
23 if (shouldStop) {
24 return;
25 }
26 if (Array.isArray(_style)) {
27 if (!_style.length) {
28 return;
29 }
30 var styles = _style;
31 var [curr, ...restStyles] = styles;
32 if (typeof curr === 'number') {
33 cancelTimeout = timeoutController.setTimeout(setStyle.bind(null, restStyles), curr);
34 return;
35 }
36 setStyle(curr);
37 cancelTimeout = timeoutController.setTimeout(setStyle.bind(null, restStyles));
38 return;
39 }
40 if (typeof _style === 'string') {
41 currStyle = _style;
42 handleChange(currStyle);
43 }
44 if (typeof _style === 'object') {
45 currStyle = _style;
46 handleChange(currStyle);
47 }
48 if (typeof _style === 'function') {
49 _style();
50 }
51 };
52 return {
53 stop: () => {
54 shouldStop = true;
55 },
56 start: style => {
57 shouldStop = false;
58 if (cancelTimeout) {
59 cancelTimeout();
60 cancelTimeout = null;
61 }
62 setStyle(style);
63 },
64 subscribe: _handleChange => {
65 handleChange = _handleChange;
66 return () => {
67 handleChange = () => null;
68 };
69 },
70 getTimeoutController: () => timeoutController
71 };
72}
Note: See TracBrowser for help on using the repository browser.