react-ui-animate 2.0.0-rc.7 → 3.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -3
- package/LICENSE +21 -21
- package/README.md +115 -115
- package/dist/animation/animationType.d.ts +15 -15
- package/dist/animation/core/animation/Animation.d.ts +16 -0
- package/dist/animation/core/animation/FluidValue.d.ts +21 -0
- package/dist/animation/core/animation/RequestAnimationFrame.d.ts +8 -0
- package/dist/animation/core/animation/SpringAnimation.d.ts +41 -0
- package/dist/animation/core/animation/TimingAnimation.d.ts +35 -0
- package/dist/animation/core/animation/TransitionValue.d.ts +21 -0
- package/dist/animation/core/controllers/Animation.d.ts +16 -0
- package/dist/animation/core/controllers/FluidValue.d.ts +32 -0
- package/dist/animation/core/controllers/RequestAnimationFrame.d.ts +8 -0
- package/dist/animation/core/controllers/SpringAnimation.d.ts +41 -0
- package/dist/animation/core/controllers/TimingAnimation.d.ts +35 -0
- package/dist/animation/core/easing/Bezier.d.ts +8 -0
- package/dist/animation/core/easing/Easing.d.ts +40 -0
- package/dist/animation/core/helpers/camelCaseToKebabCase.d.ts +8 -0
- package/dist/animation/core/helpers/camelToDash.d.ts +7 -0
- package/dist/animation/core/helpers/canInterpolate.d.ts +11 -0
- package/dist/animation/core/helpers/getAnimatableObject.d.ts +22 -0
- package/dist/animation/core/helpers/getCleanProps.d.ts +10 -0
- package/dist/animation/core/helpers/getCssValue.d.ts +8 -0
- package/dist/animation/core/helpers/getNonAnimatableStyle.d.ts +6 -0
- package/dist/animation/core/helpers/index.d.ts +5 -0
- package/dist/animation/core/helpers/isDefined.d.ts +12 -0
- package/dist/animation/core/helpers/isFluidValue.d.ts +6 -0
- package/dist/animation/core/index.d.ts +11 -0
- package/dist/animation/core/interpolation/Colors.d.ts +25 -0
- package/dist/animation/core/interpolation/Interpolation.d.ts +80 -0
- package/dist/animation/core/interpolation/__tests__/Colors.test.d.ts +1 -0
- package/dist/animation/core/react/Tags.d.ts +3 -0
- package/dist/animation/core/react/TransformStyles.d.ts +8 -0
- package/dist/animation/core/react/animated.d.ts +29 -0
- package/dist/animation/core/react/combineRefs.d.ts +2 -0
- package/dist/animation/core/react/fluid.d.ts +6 -0
- package/dist/animation/core/react/functions/camelToDash.d.ts +7 -0
- package/dist/animation/core/react/functions/getAnimatableObject.d.ts +22 -0
- package/dist/animation/core/react/functions/getCleanProps.d.ts +4 -0
- package/dist/animation/core/react/functions/getCssValue.d.ts +8 -0
- package/dist/animation/core/react/functions/getNonAnimatableStyle.d.ts +6 -0
- package/dist/animation/core/react/functions/index.d.ts +7 -0
- package/dist/animation/core/react/functions/isDefined.d.ts +6 -0
- package/dist/animation/core/react/functions/isTransitionValue.d.ts +6 -0
- package/dist/animation/core/react/helpers/camelToDash.d.ts +7 -0
- package/dist/animation/core/react/helpers/canInterpolate.d.ts +7 -0
- package/dist/animation/core/react/helpers/getAnimatableObject.d.ts +22 -0
- package/dist/animation/core/react/helpers/getCleanProps.d.ts +4 -0
- package/dist/animation/core/react/helpers/getCssValue.d.ts +8 -0
- package/dist/animation/core/react/helpers/getNonAnimatableStyle.d.ts +6 -0
- package/dist/animation/core/react/helpers/index.d.ts +7 -0
- package/dist/animation/core/react/helpers/isDefined.d.ts +6 -0
- package/dist/animation/core/react/helpers/isFluidValue.d.ts +6 -0
- package/dist/animation/core/react/helpers/isTransitionValue.d.ts +6 -0
- package/dist/animation/core/react/makeFluid.d.ts +30 -0
- package/dist/animation/core/react/transforms.d.ts +6 -0
- package/dist/animation/core/react/useFluidValue.d.ts +9 -0
- package/dist/animation/core/react/useMount.d.ts +20 -0
- package/dist/animation/core/react/useMounts.d.ts +26 -0
- package/dist/animation/core/react/useTransition.d.ts +9 -0
- package/dist/animation/core/react/useTransitions.d.ts +11 -0
- package/dist/animation/core/types/animation.d.ts +54 -0
- package/dist/animation/core/types/common.d.ts +4 -0
- package/dist/animation/core/types/fluid.d.ts +19 -0
- package/dist/animation/core/types/index.d.ts +2 -0
- package/dist/animation/getInitialConfig.d.ts +3 -3
- package/dist/animation/index.d.ts +6 -6
- package/dist/animation/interpolation.d.ts +21 -21
- package/dist/animation/lib/animationType.d.ts +15 -0
- package/dist/animation/lib/getInitialConfig.d.ts +3 -0
- package/dist/animation/lib/index.d.ts +5 -0
- package/dist/animation/lib/interpolation.d.ts +20 -0
- package/dist/animation/lib/modules/AnimatedBlock.d.ts +8 -0
- package/dist/animation/lib/modules/AnimatedImage.d.ts +8 -0
- package/dist/animation/lib/modules/AnimatedInline.d.ts +8 -0
- package/dist/animation/lib/modules/MountedBlock.d.ts +29 -0
- package/dist/animation/lib/modules/ScrollableBlock.d.ts +22 -0
- package/dist/animation/lib/modules/TransitionBlock.d.ts +18 -0
- package/dist/animation/lib/modules/index.d.ts +6 -0
- package/dist/animation/lib/useAnimatedValue.d.ts +17 -0
- package/dist/animation/lib/useMountedValue.d.ts +14 -0
- package/dist/animation/modules/AnimatedBlock.d.ts +8 -8
- package/dist/animation/modules/AnimatedImage.d.ts +8 -8
- package/dist/animation/modules/AnimatedInline.d.ts +8 -8
- package/dist/animation/modules/MountedBlock.d.ts +29 -18
- package/dist/animation/modules/ScrollableBlock.d.ts +21 -21
- package/dist/animation/modules/TransitionBlock.d.ts +17 -17
- package/dist/animation/modules/index.d.ts +6 -6
- package/dist/animation/useAnimatedValue.d.ts +22 -22
- package/dist/animation/useMountedValue.d.ts +15 -15
- package/dist/gestures/controllers/DragGesture.d.ts +17 -17
- package/dist/gestures/controllers/Gesture.d.ts +20 -20
- package/dist/gestures/controllers/MouseMoveGesture.d.ts +13 -13
- package/dist/gestures/controllers/ScrollGesture.d.ts +14 -14
- package/dist/gestures/controllers/WheelGesture.d.ts +15 -15
- package/dist/gestures/controllers/index.d.ts +4 -4
- package/dist/gestures/eventAttacher.d.ts +11 -11
- package/dist/gestures/helpers/eventAttacher.d.ts +11 -0
- package/dist/gestures/helpers/index.d.ts +1 -0
- package/dist/gestures/helpers/math.d.ts +34 -0
- package/dist/gestures/helpers/withDefault.d.ts +4 -0
- package/dist/gestures/hooks/index.d.ts +5 -5
- package/dist/gestures/hooks/useDrag.d.ts +4 -4
- package/dist/gestures/hooks/useGesture.d.ts +9 -9
- package/dist/gestures/hooks/useMouseMove.d.ts +4 -4
- package/dist/gestures/hooks/useRecognizer.d.ts +10 -10
- package/dist/gestures/hooks/useScroll.d.ts +4 -4
- package/dist/gestures/hooks/useWheel.d.ts +4 -4
- package/dist/gestures/index.d.ts +2 -2
- package/dist/gestures/math.d.ts +34 -34
- package/dist/gestures/types.d.ts +51 -51
- package/dist/gestures/withDefault.d.ts +4 -4
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/useMeasure.d.ts +14 -14
- package/dist/hooks/useOutsideClick.d.ts +2 -2
- package/dist/hooks/useWindowDimension.d.ts +9 -9
- package/dist/index.d.ts +9 -5
- package/dist/index.js +2758 -1052
- package/dist/index.js.map +1 -1
- package/dist/utils/delay.d.ts +5 -5
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/isDefined.d.ts +1 -1
- package/ecosystem.config.js +12 -0
- package/example/README.md +46 -0
- package/example/package-lock.json +19597 -0
- package/example/package.json +45 -0
- package/example/public/favicon.ico +0 -0
- package/example/public/index.html +20 -0
- package/example/public/logo192.png +0 -0
- package/example/public/logo512.png +0 -0
- package/example/public/manifest.json +25 -0
- package/example/public/robots.txt +3 -0
- package/example/src/App.tsx +41 -0
- package/example/src/components/Draggable.tsx +46 -0
- package/example/src/components/Gestures.tsx +151 -0
- package/example/src/components/Interpolation.tsx +21 -0
- package/example/src/components/Loop.tsx +48 -0
- package/example/src/components/MountedBlock.tsx +25 -0
- package/example/src/components/MouseMove.tsx +59 -0
- package/example/src/components/MultistageTransition.tsx +34 -0
- package/example/src/components/Scroll.tsx +39 -0
- package/example/src/components/ScrollableBlock.tsx +27 -0
- package/example/src/components/SnapTo.tsx +55 -0
- package/example/src/components/TransitionBlock.tsx +37 -0
- package/example/src/components/Wheel.tsx +39 -0
- package/example/src/components/index.ts +18 -0
- package/example/src/components/svgLine.tsx +48 -0
- package/example/src/components/useAnimatedValue.tsx +57 -0
- package/example/src/components/useMountedValue.tsx +62 -0
- package/example/src/index.css +8 -0
- package/example/src/index.tsx +16 -0
- package/example/tsconfig.json +26 -0
- package/package.json +48 -48
- package/{rollup.config.js → rollup.config.mjs} +18 -18
- package/src/animation/core/controllers/Animation.ts +27 -0
- package/src/animation/core/controllers/FluidValue.ts +97 -0
- package/src/animation/core/controllers/RequestAnimationFrame.ts +13 -0
- package/src/animation/core/controllers/SpringAnimation.ts +218 -0
- package/src/animation/core/controllers/TimingAnimation.ts +152 -0
- package/src/animation/core/easing/Bezier.ts +146 -0
- package/src/animation/core/easing/Easing.ts +132 -0
- package/src/animation/core/helpers/camelCaseToKebabCase.ts +10 -0
- package/src/animation/core/helpers/getCleanProps.ts +16 -0
- package/src/animation/core/helpers/getCssValue.ts +60 -0
- package/src/animation/core/helpers/index.ts +5 -0
- package/src/animation/core/helpers/isDefined.ts +14 -0
- package/src/animation/core/helpers/isFluidValue.ts +11 -0
- package/src/animation/core/index.ts +16 -0
- package/src/animation/core/interpolation/Colors.ts +232 -0
- package/src/animation/core/interpolation/Interpolation.ts +395 -0
- package/src/animation/core/interpolation/__tests__/Colors.test.tsx +35 -0
- package/src/animation/core/react/fluid.ts +197 -0
- package/src/animation/core/react/makeFluid.ts +294 -0
- package/src/animation/core/react/transforms.ts +90 -0
- package/src/animation/core/react/useFluidValue.ts +43 -0
- package/src/animation/core/react/useMount.ts +58 -0
- package/src/animation/core/types/animation.d.ts +56 -0
- package/src/animation/core/types/common.d.ts +4 -0
- package/src/animation/core/types/fluid.d.ts +38 -0
- package/src/animation/{animationType.ts → lib/animationType.ts} +17 -17
- package/src/animation/{getInitialConfig.ts → lib/getInitialConfig.ts} +61 -61
- package/src/animation/lib/index.ts +12 -0
- package/src/animation/{interpolation.ts → lib/interpolation.ts} +47 -48
- package/src/animation/{modules → lib/modules}/AnimatedBlock.ts +8 -8
- package/src/animation/{modules → lib/modules}/AnimatedImage.ts +8 -8
- package/src/animation/{modules → lib/modules}/AnimatedInline.ts +8 -8
- package/src/animation/lib/modules/MountedBlock.tsx +51 -0
- package/src/animation/{modules → lib/modules}/ScrollableBlock.tsx +68 -69
- package/src/animation/{modules → lib/modules}/TransitionBlock.tsx +28 -29
- package/src/animation/{modules → lib/modules}/index.ts +6 -6
- package/src/animation/{useAnimatedValue.ts → lib/useAnimatedValue.ts} +60 -71
- package/src/animation/{useMountedValue.ts → lib/useMountedValue.ts} +18 -19
- package/src/gestures/controllers/DragGesture.ts +178 -177
- package/src/gestures/controllers/Gesture.ts +54 -54
- package/src/gestures/controllers/MouseMoveGesture.ts +111 -111
- package/src/gestures/controllers/ScrollGesture.ts +107 -107
- package/src/gestures/controllers/WheelGesture.ts +123 -123
- package/src/gestures/controllers/index.ts +4 -4
- package/src/gestures/{eventAttacher.ts → helpers/eventAttacher.ts} +67 -67
- package/src/gestures/helpers/index.ts +1 -0
- package/src/gestures/{math.ts → helpers/math.ts} +120 -120
- package/src/gestures/{withDefault.ts → helpers/withDefault.ts} +3 -3
- package/src/gestures/hooks/index.ts +5 -5
- package/src/gestures/hooks/useDrag.ts +14 -14
- package/src/gestures/hooks/useGesture.ts +38 -38
- package/src/gestures/hooks/useMouseMove.ts +11 -11
- package/src/gestures/hooks/useRecognizer.ts +59 -59
- package/src/gestures/hooks/useScroll.ts +11 -11
- package/src/gestures/hooks/useWheel.ts +11 -11
- package/src/gestures/{types.ts → types/index.d.ts} +49 -49
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useMeasure.ts +132 -133
- package/src/hooks/useOutsideClick.ts +36 -36
- package/src/hooks/useWindowDimension.ts +58 -59
- package/src/index.ts +42 -5
- package/src/utils/delay.ts +9 -9
- package/src/utils/index.ts +1 -2
- package/tsconfig.json +24 -25
- package/src/animation/index.ts +0 -10
- package/src/animation/modules/MountedBlock.tsx +0 -25
- package/src/gestures/index.ts +0 -2
- package/src/utils/isDefined.ts +0 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines if two values can be interpolated.
|
|
3
|
+
* This function checks if two values, either numbers or strings,
|
|
4
|
+
* can be interpolated by ensuring they are of the same type and, in the case of strings,
|
|
5
|
+
* that they are compatible for interpolation based on processed color values.
|
|
6
|
+
*
|
|
7
|
+
* @param previousValue - The previous value to compare. Can be a number or a string.
|
|
8
|
+
* @param newValue - The new value to compare. Can be a number or a string.
|
|
9
|
+
* @returns True if interpolation is possible, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export declare function canInterpolate(previousValue: number | string, newValue: number | string): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExtrapolateConfig } from '../interpolation/Interpolation';
|
|
2
|
+
import { FluidValue } from '../controllers/FluidValue';
|
|
3
|
+
type PropertyType = 'style' | 'props';
|
|
4
|
+
export type AnimationObject = {
|
|
5
|
+
propertyType: PropertyType;
|
|
6
|
+
property: string;
|
|
7
|
+
animatable: boolean;
|
|
8
|
+
isInterpolation: boolean;
|
|
9
|
+
interpolationConfig: {
|
|
10
|
+
inputRange: Array<number>;
|
|
11
|
+
outputRange: Array<number | string>;
|
|
12
|
+
extrapolateConfig?: ExtrapolateConfig;
|
|
13
|
+
};
|
|
14
|
+
} & FluidValue;
|
|
15
|
+
/**
|
|
16
|
+
* Function to get the array of animatable objects
|
|
17
|
+
* @param propertyType - which property type "props" or "style"
|
|
18
|
+
*/
|
|
19
|
+
export declare function getAnimatableObject(propertyType: PropertyType, propertiesObject: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}): Array<AnimationObject>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters out properties with fluid values from a given props object.
|
|
3
|
+
* This function removes any properties that are considered fluid values,
|
|
4
|
+
* typically those that subscribe to updates and therefore should not be
|
|
5
|
+
* included in a static props object.
|
|
6
|
+
*
|
|
7
|
+
* @param props - The original props object, which may include fluid values.
|
|
8
|
+
* @returns A new props object with fluid values removed.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getCleanProps: ({ style, ...props }: any) => any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getCssValue() function to get css value with unit or without unit
|
|
3
|
+
* it is only for style property - it cannot be used with transform keys
|
|
4
|
+
* @param property - style property
|
|
5
|
+
* @param value - style value
|
|
6
|
+
* @returns - value with unit or without unit
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCssValue(property: string, value: number | string): string | number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getNonAnimatableStyle function returns the non-animatable style object
|
|
3
|
+
* @param style - CSSProperties
|
|
4
|
+
* @returns - non-animatable CSSProperties
|
|
5
|
+
*/
|
|
6
|
+
export declare function getNonAnimatableStyle(style: React.CSSProperties, transformObjectRef: React.MutableRefObject<any>): any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is defined (not null or undefined).
|
|
3
|
+
*
|
|
4
|
+
* This utility function helps in determining whether a given value is neither `null` nor `undefined`.
|
|
5
|
+
* It can be useful for validation checks to ensure that a value is properly defined before proceeding
|
|
6
|
+
* with further operations.
|
|
7
|
+
*
|
|
8
|
+
* @param {T} value - The value to check.
|
|
9
|
+
* @returns {boolean} - Returns `true` if the value is neither `null` nor `undefined`, otherwise returns `false`.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare const isDefined: <T>(value: T) => value is T & {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { fluid } from './react/fluid';
|
|
2
|
+
export { makeFluid } from './react/makeFluid';
|
|
3
|
+
export { useFluidValue } from './react/useFluidValue';
|
|
4
|
+
export { useMount } from './react/useMount';
|
|
5
|
+
export { isFluidValue } from './helpers/isFluidValue';
|
|
6
|
+
export { Easing } from './easing/Easing';
|
|
7
|
+
export { interpolate } from './interpolation/Interpolation';
|
|
8
|
+
export { FluidValue } from './controllers/FluidValue';
|
|
9
|
+
export type { FluidValueConfig } from './types/animation';
|
|
10
|
+
export type { UseMountConfig } from './react/useMount';
|
|
11
|
+
export type { ExtrapolateConfig } from './interpolation/Interpolation';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const COLOR_NUMBER_REGEX: RegExp;
|
|
2
|
+
export declare const HEX_NAME_COLOR: RegExp;
|
|
3
|
+
interface classNameType {
|
|
4
|
+
[name: string]: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const colorNames: classNameType;
|
|
7
|
+
export declare function hexToRgba(hex: string): {
|
|
8
|
+
r: number;
|
|
9
|
+
g: number;
|
|
10
|
+
b: number;
|
|
11
|
+
a: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function rgbaToHex(rgba: {
|
|
14
|
+
r: number;
|
|
15
|
+
g: number;
|
|
16
|
+
b: number;
|
|
17
|
+
a: number;
|
|
18
|
+
}): string;
|
|
19
|
+
export declare function processColor(color: number | string): {
|
|
20
|
+
r: number;
|
|
21
|
+
g: number;
|
|
22
|
+
b: number;
|
|
23
|
+
a: number;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { FluidValue } from '../controllers/FluidValue';
|
|
2
|
+
type ExtrapolateType = 'identity' | 'extend' | 'clamp';
|
|
3
|
+
export declare const _getTemplateString: (str: string) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Function returns if the template of two strings are matched
|
|
6
|
+
* i.e. they can be interpolated
|
|
7
|
+
* @param str1 - first string
|
|
8
|
+
* @param str2 - second string
|
|
9
|
+
* @returns boolean indicating two strings matched or not
|
|
10
|
+
*/
|
|
11
|
+
export declare const stringMatched: (str1: string, str2: string) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Function which proccess the
|
|
14
|
+
* hexadecimal colors to its proper formats
|
|
15
|
+
* @param str - string
|
|
16
|
+
* @returns hex color string
|
|
17
|
+
*/
|
|
18
|
+
export declare const getProcessedColor: (str: string) => string;
|
|
19
|
+
export interface ExtrapolateConfig {
|
|
20
|
+
extrapolate?: ExtrapolateType;
|
|
21
|
+
extrapolateRight?: ExtrapolateType;
|
|
22
|
+
extrapolateLeft?: ExtrapolateType;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* interpolateNumbers to interpolate the numeric value
|
|
26
|
+
* @param value - number
|
|
27
|
+
* @param inputRange
|
|
28
|
+
* @param outputRange
|
|
29
|
+
* @param extrapolateConfig
|
|
30
|
+
* @returns - number | string
|
|
31
|
+
*/
|
|
32
|
+
export declare function interpolateNumbers(value: number, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig): any;
|
|
33
|
+
/**
|
|
34
|
+
* interpolateTransitionValue to interpolating TransitionValue type value
|
|
35
|
+
* @param value
|
|
36
|
+
* @param inputRange
|
|
37
|
+
* @param outputRange
|
|
38
|
+
* @param extrapolateConfig
|
|
39
|
+
* @returns TransitionValue
|
|
40
|
+
*/
|
|
41
|
+
export declare const interpolateTransitionValue: (value: FluidValue, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig) => {
|
|
42
|
+
isInterpolation: boolean;
|
|
43
|
+
interpolationConfig: {
|
|
44
|
+
inputRange: number[];
|
|
45
|
+
outputRange: (string | number)[];
|
|
46
|
+
extrapolateConfig: ExtrapolateConfig | undefined;
|
|
47
|
+
};
|
|
48
|
+
_subscribe: import("../types/animation").SubscribeFn;
|
|
49
|
+
_value: import("../types/animation").Length;
|
|
50
|
+
_config?: import("..").FluidValueConfig;
|
|
51
|
+
_currentValue: {
|
|
52
|
+
current: import("../types/animation").Length;
|
|
53
|
+
};
|
|
54
|
+
_subscriptions: Map<{
|
|
55
|
+
uuid: number;
|
|
56
|
+
property: string;
|
|
57
|
+
}, import("../types/animation").OnUpdateFn>;
|
|
58
|
+
get: () => import("../types/animation").Length;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* interpolate function to interpolate both transition
|
|
62
|
+
* as well as numerical value
|
|
63
|
+
* @param value
|
|
64
|
+
* @param inputRange
|
|
65
|
+
* @param outputRange
|
|
66
|
+
* @param extrapolateConfig
|
|
67
|
+
*/
|
|
68
|
+
export declare const interpolate: (value: number | FluidValue, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig) => any;
|
|
69
|
+
/**
|
|
70
|
+
* Determines if two values can be interpolated.
|
|
71
|
+
* This function checks if two values, either numbers or strings,
|
|
72
|
+
* can be interpolated by ensuring they are of the same type and, in the case of strings,
|
|
73
|
+
* that they are compatible for interpolation based on processed color values.
|
|
74
|
+
*
|
|
75
|
+
* @param previousValue - The previous value to compare. Can be a number or a string.
|
|
76
|
+
* @param newValue - The new value to compare. Can be a number or a string.
|
|
77
|
+
* @returns True if interpolation is possible, false otherwise.
|
|
78
|
+
*/
|
|
79
|
+
export declare function canInterpolate(previousValue: number | string, newValue: number | string): boolean;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* style keys which can be accepted by animated component
|
|
3
|
+
*/
|
|
4
|
+
export declare const styleTrasformKeys: readonly ["perspective", "translate", "translateX", "translateY", "translateZ", "scale", "scaleX", "scaleY", "scaleZ", "rotate", "rotateX", "rotateY", "rotateZ", "skew", "skewX", "skewY"];
|
|
5
|
+
/**
|
|
6
|
+
* getTransform function returns transform string from style object
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTransform(style: any): any;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FluidValue } from '../types';
|
|
2
|
+
import { styleTrasformKeys } from './TransformStyles';
|
|
3
|
+
export type AnimatedCSSProperties = {
|
|
4
|
+
[key in keyof React.CSSProperties]: React.CSSProperties[key] | any;
|
|
5
|
+
} & {
|
|
6
|
+
[key in (typeof styleTrasformKeys)[number]]?: number | string | FluidValue | any;
|
|
7
|
+
};
|
|
8
|
+
export type AnimatedHTMLAttributes<T> = {
|
|
9
|
+
[property in keyof React.HTMLAttributes<T>]: React.HTMLAttributes<T>[property] | FluidValue | any;
|
|
10
|
+
};
|
|
11
|
+
export type AnimatedSVGAttributes<T> = {
|
|
12
|
+
[property in keyof React.SVGAttributes<T>]: React.SVGAttributes<T>[property] | FluidValue | any;
|
|
13
|
+
};
|
|
14
|
+
export type AnimatedProps<T> = Omit<AnimatedHTMLAttributes<T> & AnimatedSVGAttributes<T>, 'style'> & {
|
|
15
|
+
style?: AnimatedCSSProperties;
|
|
16
|
+
};
|
|
17
|
+
type WrappedComponentOrTag = React.ComponentType<any> | keyof JSX.IntrinsicElements;
|
|
18
|
+
/**
|
|
19
|
+
* Higher order component to make any component animatable
|
|
20
|
+
* @param WrapperComponent
|
|
21
|
+
*/
|
|
22
|
+
export declare function makeAnimatedComponent<C extends WrappedComponentOrTag>(WrapperComponent: C): import("react").ForwardRefExoticComponent<Omit<AnimatedHTMLAttributes<C> & AnimatedSVGAttributes<C>, "style"> & {
|
|
23
|
+
style?: AnimatedCSSProperties;
|
|
24
|
+
} & import("react").RefAttributes<unknown>>;
|
|
25
|
+
type WithAnimated = {
|
|
26
|
+
[element in keyof JSX.IntrinsicElements]: React.ComponentType<AnimatedProps<element>>;
|
|
27
|
+
} & any;
|
|
28
|
+
export declare const animated: WithAnimated;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExtrapolateConfig } from '../../interpolation/Interpolation';
|
|
2
|
+
import type { FluidValue } from '../../types';
|
|
3
|
+
type PropertyType = 'style' | 'props';
|
|
4
|
+
export type AnimationObject = {
|
|
5
|
+
propertyType: PropertyType;
|
|
6
|
+
property: string;
|
|
7
|
+
animatable: boolean;
|
|
8
|
+
isInterpolation: boolean;
|
|
9
|
+
interpolationConfig: {
|
|
10
|
+
inputRange: Array<number>;
|
|
11
|
+
outputRange: Array<number | string>;
|
|
12
|
+
extrapolateConfig?: ExtrapolateConfig;
|
|
13
|
+
};
|
|
14
|
+
} & FluidValue;
|
|
15
|
+
/**
|
|
16
|
+
* Function to get the array of animatable objects
|
|
17
|
+
* @param propertyType - which property type "props" or "style"
|
|
18
|
+
*/
|
|
19
|
+
export declare function getAnimatableObject(propertyType: PropertyType, propertiesObject: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}): Array<AnimationObject>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getCssValue() function to get css value with unit or without unit
|
|
3
|
+
* it is only for style property - it cannot be used with transform keys
|
|
4
|
+
* @param property - style property
|
|
5
|
+
* @param value - style value
|
|
6
|
+
* @returns - value with unit or without unit
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCssValue(property: string, value: number | string): string | number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getNonAnimatableStyle function returns the non-animatable style object
|
|
3
|
+
* @param style - CSSProperties
|
|
4
|
+
* @returns - non-animatable CSSProperties
|
|
5
|
+
*/
|
|
6
|
+
export declare function getNonAnimatableStyle(style: React.CSSProperties, transformObjectRef: React.MutableRefObject<any>): any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines if two values can be interpolated.
|
|
3
|
+
* @param previousValue - The previous value to compare.
|
|
4
|
+
* @param newValue - The new value to compare.
|
|
5
|
+
* @returns True if interpolation is possible, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function canInterpolate(previousValue: number | string, newValue: number | string): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExtrapolateConfig } from '../../interpolation/Interpolation';
|
|
2
|
+
import { FluidValue } from '../../controllers/FluidValue';
|
|
3
|
+
type PropertyType = 'style' | 'props';
|
|
4
|
+
export type AnimationObject = {
|
|
5
|
+
propertyType: PropertyType;
|
|
6
|
+
property: string;
|
|
7
|
+
animatable: boolean;
|
|
8
|
+
isInterpolation: boolean;
|
|
9
|
+
interpolationConfig: {
|
|
10
|
+
inputRange: Array<number>;
|
|
11
|
+
outputRange: Array<number | string>;
|
|
12
|
+
extrapolateConfig?: ExtrapolateConfig;
|
|
13
|
+
};
|
|
14
|
+
} & FluidValue;
|
|
15
|
+
/**
|
|
16
|
+
* Function to get the array of animatable objects
|
|
17
|
+
* @param propertyType - which property type "props" or "style"
|
|
18
|
+
*/
|
|
19
|
+
export declare function getAnimatableObject(propertyType: PropertyType, propertiesObject: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}): Array<AnimationObject>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getCssValue() function to get css value with unit or without unit
|
|
3
|
+
* it is only for style property - it cannot be used with transform keys
|
|
4
|
+
* @param property - style property
|
|
5
|
+
* @param value - style value
|
|
6
|
+
* @returns - value with unit or without unit
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCssValue(property: string, value: number | string): string | number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getNonAnimatableStyle function returns the non-animatable style object
|
|
3
|
+
* @param style - CSSProperties
|
|
4
|
+
* @returns - non-animatable CSSProperties
|
|
5
|
+
*/
|
|
6
|
+
export declare function getNonAnimatableStyle(style: React.CSSProperties, transformObjectRef: React.MutableRefObject<any>): any;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WrappedComponentOrTag } from '../types/fluid';
|
|
2
|
+
/**
|
|
3
|
+
* Higher-order component to make any component animatable.
|
|
4
|
+
*
|
|
5
|
+
* This function takes a React component or an HTML tag and returns a new component
|
|
6
|
+
* that can smoothly transition between states using fluid animations. It enhances
|
|
7
|
+
* the user experience by adding dynamic and engaging animations to the wrapped component.
|
|
8
|
+
*
|
|
9
|
+
* @param WrapperComponent - The React component or HTML tag to be wrapped with animation functionality.
|
|
10
|
+
* @returns - A new component with added animation capabilities.
|
|
11
|
+
*
|
|
12
|
+
* The returned component uses fluid animations to smoothly transition between different
|
|
13
|
+
* states. It supports both style and prop animations, handling transforms and other
|
|
14
|
+
* properties seamlessly. The component ensures that animations are efficiently applied
|
|
15
|
+
* and updated based on the current state and configuration of fluid values.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const AnimatedDiv = makeFluid('div');
|
|
19
|
+
*
|
|
20
|
+
* const MyComponent = () => {
|
|
21
|
+
* const opacity = useAnimatedValue(1)
|
|
22
|
+
* return (
|
|
23
|
+
* <AnimatedDiv style={{ opacity: opacity.value }}>
|
|
24
|
+
* Hello, world!
|
|
25
|
+
* </AnimatedDiv>
|
|
26
|
+
* )};
|
|
27
|
+
*/
|
|
28
|
+
export declare function makeFluid<C extends WrappedComponentOrTag>(WrapperComponent: C): import("react").ForwardRefExoticComponent<Omit<import("../types/fluid").FluidHTMLAttributes<C> & import("../types/fluid").FluidSVGAttributes<C>, "style"> & {
|
|
29
|
+
style?: import("../types/fluid").FluidCSSProperties;
|
|
30
|
+
} & import("react").RefAttributes<unknown>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const styleTrasformKeys: readonly ["translate", "translateX", "translateY", "translateZ", "scale", "scaleX", "scaleY", "scaleZ", "rotate", "rotateX", "rotateY", "rotateZ", "skew", "skewX", "skewY"];
|
|
2
|
+
/**
|
|
3
|
+
* getTransform function returns transform string from style object
|
|
4
|
+
*/
|
|
5
|
+
export declare function getTransform(style: Record<string, any>): string;
|
|
6
|
+
export declare function isTransformKey(key: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FluidValue } from '../controllers/FluidValue';
|
|
2
|
+
import type { FluidValueConfig, Length, AssignValue, OnUpdateCallback } from '../types/animation';
|
|
3
|
+
/**
|
|
4
|
+
* useFluidValue
|
|
5
|
+
*
|
|
6
|
+
* @param value - initial value
|
|
7
|
+
* @param config - the config object for `FluidValue`
|
|
8
|
+
*/
|
|
9
|
+
export declare const useFluidValue: (value: Length, config?: FluidValueConfig) => [FluidValue, (updateValue: AssignValue, config?: FluidValueConfig, callback?: OnUpdateCallback) => void];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FluidValue } from '../controllers/FluidValue';
|
|
2
|
+
import type { AssignValue, FluidValueConfig } from '../types/animation';
|
|
3
|
+
export interface UseMountConfig {
|
|
4
|
+
from: number;
|
|
5
|
+
enter: number | AssignValue;
|
|
6
|
+
exit: number | AssignValue;
|
|
7
|
+
enterConfig?: FluidValueConfig;
|
|
8
|
+
exitConfig?: FluidValueConfig;
|
|
9
|
+
config?: FluidValueConfig;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `useMount`
|
|
13
|
+
*
|
|
14
|
+
* applies mounting and unmounting of a component according to state change
|
|
15
|
+
* applying transitions
|
|
16
|
+
*
|
|
17
|
+
* @param state - boolean indicating mount state of a component
|
|
18
|
+
* @param config - the config object `UseMountConfig`
|
|
19
|
+
*/
|
|
20
|
+
export declare const useMount: (state: boolean, config: UseMountConfig) => (callback: (animation: FluidValue, mounted: boolean) => React.ReactNode) => import("react").ReactNode;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TransitionValue } from '../animation/TransitionValue';
|
|
2
|
+
import type { AssignValue, Length, TransitionValueConfig } from '../types/animation';
|
|
3
|
+
export interface UseMountsConfig<T> {
|
|
4
|
+
from: T;
|
|
5
|
+
enter: Partial<{
|
|
6
|
+
[key in keyof T]: AssignValue;
|
|
7
|
+
}>;
|
|
8
|
+
exit: Partial<{
|
|
9
|
+
[key in keyof T]: AssignValue;
|
|
10
|
+
}>;
|
|
11
|
+
enterConfig?: TransitionValueConfig;
|
|
12
|
+
exitConfig?: TransitionValueConfig;
|
|
13
|
+
config?: TransitionValueConfig;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `useMounts`
|
|
17
|
+
*
|
|
18
|
+
* applies mounting and unmounting of a component according to state change
|
|
19
|
+
* applying transitions for multiple keys
|
|
20
|
+
*
|
|
21
|
+
* @param state - boolean indicating mount state of a component
|
|
22
|
+
* @param config - the config object `UseMountsConfig`
|
|
23
|
+
*/
|
|
24
|
+
export declare const useMounts: <T extends {
|
|
25
|
+
[key: string]: Length;
|
|
26
|
+
}>(state: boolean, config: UseMountsConfig<T>) => (callback: (animation: { [key in keyof T]?: TransitionValue; }, mounted: boolean) => React.ReactNode) => import("react").ReactNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FluidValue } from '../controllers/FluidValue';
|
|
2
|
+
import type { FluidValueConfig, Length, AssignValue, OnUpdateCallback } from '../types/animation';
|
|
3
|
+
/**
|
|
4
|
+
* useTransition
|
|
5
|
+
*
|
|
6
|
+
* @param value - initial value
|
|
7
|
+
* @param config - the config object for `FluidValue`
|
|
8
|
+
*/
|
|
9
|
+
export declare const useTransition: (value: Length, config?: FluidValueConfig) => [FluidValue, (updateValue: AssignValue, config?: FluidValueConfig, callback?: OnUpdateCallback) => void];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TransitionValue } from '../animation/TransitionValue';
|
|
2
|
+
import type { TransitionValueConfig, Length, AssignValue, OnUpdateCallback } from '../types/animation';
|
|
3
|
+
/**
|
|
4
|
+
* useTransitions hook for multiple values transition
|
|
5
|
+
*
|
|
6
|
+
* @param values - object with different keys
|
|
7
|
+
* @param config - the config object for `TransitionValue`
|
|
8
|
+
*/
|
|
9
|
+
export declare const useTransitions: <T extends {
|
|
10
|
+
[key: string]: Length;
|
|
11
|
+
}>(values: T, config?: TransitionValueConfig) => [{ [key in keyof T]?: TransitionValue; }, (updateValues: Partial<{ [key in keyof T]?: AssignValue; }>, config?: TransitionValueConfig, callback?: OnUpdateCallback) => void];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Fn } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* Base unit which is accepted by `TransitionValue`
|
|
4
|
+
*/
|
|
5
|
+
export type Length = number | string;
|
|
6
|
+
/**
|
|
7
|
+
* Object passed as an argument on `onRest` function
|
|
8
|
+
*/
|
|
9
|
+
export type ResultType = {
|
|
10
|
+
finished: boolean;
|
|
11
|
+
value: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Function read by `animated` hoc to determine whether it
|
|
15
|
+
* can be animated or not
|
|
16
|
+
*/
|
|
17
|
+
export type SubscribeFn = (onUpdate: OnUpdateFn, property: string, uuid: number) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Configuration object for `TransitionValue`
|
|
20
|
+
*/
|
|
21
|
+
export interface TransitionValueConfig {
|
|
22
|
+
mass?: number;
|
|
23
|
+
tension?: number;
|
|
24
|
+
friction?: number;
|
|
25
|
+
duration?: number;
|
|
26
|
+
easing?: Fn<number, number>;
|
|
27
|
+
immediate?: boolean;
|
|
28
|
+
delay?: number;
|
|
29
|
+
restDistance?: number;
|
|
30
|
+
onChange?: Fn<number, void>;
|
|
31
|
+
onRest?: Fn<ResultType, void>;
|
|
32
|
+
onStart?: Fn<number, void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* FluidValue
|
|
36
|
+
*/
|
|
37
|
+
export type FluidValue = {
|
|
38
|
+
_subscribe: SubscribeFn;
|
|
39
|
+
_value: Length;
|
|
40
|
+
_currentValue: {
|
|
41
|
+
current: Length;
|
|
42
|
+
};
|
|
43
|
+
_config?: TransitionValueConfig;
|
|
44
|
+
get: () => Length;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Object which can be assigned to animate
|
|
48
|
+
*/
|
|
49
|
+
export type AssignValue = Length | Fn<(next: Length, config?: TransitionValueConfig) => Promise<any>, void>;
|
|
50
|
+
export type OnUpdateCallback = Fn<ResultType, void>;
|
|
51
|
+
/**
|
|
52
|
+
* Function to start the animation (it starts the already subscribed animation)
|
|
53
|
+
*/
|
|
54
|
+
export type OnUpdateFn = (updatedValue: AssignValue, config?: TransitionValueConfig, callback?: OnUpdateCallback) => void;
|