victory-core
Version:
67 lines • 3.21 kB
TypeScript
export declare const isInterpolatable: (obj: any) => boolean;
/**
* Interpolate immediately to the end value at the given step `when`.
* Some nicer default behavior might be to jump at the halfway point or return
* `a` if `t` is 0 (instead of always returning `b`). But d3's default
* interpolator does not do these things:
*
* d3.interpolate('aaa', 'bbb')(0) === 'bbb'
*
* ...and things might get wonky if we don't replicate that behavior.
*
* @param {any} a - Start value.
* @param {any} b - End value.
* @param {Number} when - Step value (0 to 1) at which to jump to `b`.
* @returns {Function} An interpolation function.
*/
export declare const interpolateImmediate: (a: any, b: any, when?: number) => (t: any) => any;
/**
* Interpolate to or from a function. The interpolated value will be a function
* that calls `a` (if it's a function) and `b` (if it's a function) and calls
* `d3.interpolate` on the resulting values. Note that our function won't
* necessarily be called (that's up to the component this eventually gets
* passed to) - but if it does get called, it will return an appropriately
* interpolated value.
*
* @param {any} a - Start value.
* @param {any} b - End value.
* @returns {Function} An interpolation function.
*/
export declare const interpolateFunction: (a: any, b: any) => (t: any) => any;
/**
* Interpolate to or from an object. This method is a modification of the object interpolator in
* d3-interpolate https://github.com/d3/d3-interpolate/blob/master/src/object.js. This interpolator
* differs in that it uses our custom interpolators when interpolating the value of each property in
* an object. This allows the correct interpolation of nested objects, including styles
*
* @param {any} startValue - Start value.
* @param {any} endValue - End value.
* @returns {Function} An interpolation function.
*/
export declare const interpolateObject: (startValue: any, endValue: any) => (t: any) => {};
export declare const interpolateString: (a: any, b: any) => (t: number) => any;
/**
* By default, the list of interpolators used by `d3.interpolate` has a few
* downsides:
*
* - `null` values get turned into 0.
* - `undefined`, `function`, and some other value types get turned into NaN.
* - Boolean types get turned into numbers, which probably will be meaningless
* to whatever is consuming them.
* - It tries to interpolate between identical start and end values, doing
* unnecessary calculations that sometimes result in floating point rounding
* errors.
*
* If only the default interpolators are used, `VictoryAnimation` will happily
* pass down NaN (and other bad) values as props to the wrapped component.
* The component will then either use the incorrect values or complain that it
* was passed props of the incorrect type. This custom interpolator is added
* using the `d3.interpolators` API, and prevents such cases from happening
* for most values.
*
* @param {any} a - Start value.
* @param {any} b - End value.
* @returns {Function|undefined} An interpolation function, if necessary.
*/
export declare const victoryInterpolator: <T>(a: T, b: T) => (t: number) => T;
//# sourceMappingURL=util.d.ts.map