react-ui-animate 2.0.0 → 3.0.0-rc.1
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/LICENSE +21 -21
- package/README.md +115 -115
- 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/getCleanProps.d.ts +10 -0
- package/dist/animation/core/helpers/getCssValue.d.ts +8 -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/fluid.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/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/{interpolation.d.ts → lib/interpolation.d.ts} +20 -21
- 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/{modules → lib/modules}/ScrollableBlock.d.ts +22 -21
- package/dist/animation/{modules → lib/modules}/TransitionBlock.d.ts +18 -17
- package/dist/animation/{modules → lib/modules}/index.d.ts +6 -6
- package/dist/animation/{useAnimatedValue.d.ts → lib/useAnimatedValue.d.ts} +17 -22
- package/dist/animation/{useMountedValue.d.ts → lib/useMountedValue.d.ts} +14 -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/helpers/eventAttacher.d.ts +11 -0
- package/dist/gestures/helpers/index.d.ts +1 -0
- package/dist/gestures/{math.d.ts → helpers/math.d.ts} +34 -34
- package/dist/gestures/{withDefault.d.ts → helpers/withDefault.d.ts} +4 -4
- 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/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 +1 -1191
- package/dist/index.js.map +1 -1
- package/dist/utils/delay.d.ts +5 -5
- package/dist/utils/index.d.ts +1 -2
- package/package.json +49 -48
- package/.vscode/settings.json +0 -3
- package/dist/animation/animationType.d.ts +0 -15
- package/dist/animation/getInitialConfig.d.ts +0 -3
- package/dist/animation/index.d.ts +0 -6
- package/dist/animation/modules/AnimatedBlock.d.ts +0 -8
- package/dist/animation/modules/AnimatedImage.d.ts +0 -8
- package/dist/animation/modules/AnimatedInline.d.ts +0 -8
- package/dist/animation/modules/MountedBlock.d.ts +0 -18
- package/dist/gestures/eventAttacher.d.ts +0 -11
- package/dist/gestures/index.d.ts +0 -2
- package/dist/gestures/types.d.ts +0 -51
- package/dist/utils/isDefined.d.ts +0 -1
- package/rollup.config.js +0 -18
- package/src/animation/animationType.ts +0 -17
- package/src/animation/getInitialConfig.ts +0 -61
- package/src/animation/index.ts +0 -10
- package/src/animation/interpolation.ts +0 -48
- package/src/animation/modules/AnimatedBlock.ts +0 -8
- package/src/animation/modules/AnimatedImage.ts +0 -8
- package/src/animation/modules/AnimatedInline.ts +0 -8
- package/src/animation/modules/MountedBlock.tsx +0 -25
- package/src/animation/modules/ScrollableBlock.tsx +0 -69
- package/src/animation/modules/TransitionBlock.tsx +0 -29
- package/src/animation/modules/index.ts +0 -6
- package/src/animation/useAnimatedValue.ts +0 -71
- package/src/animation/useMountedValue.ts +0 -19
- package/src/gestures/controllers/DragGesture.ts +0 -177
- package/src/gestures/controllers/Gesture.ts +0 -54
- package/src/gestures/controllers/MouseMoveGesture.ts +0 -111
- package/src/gestures/controllers/ScrollGesture.ts +0 -107
- package/src/gestures/controllers/WheelGesture.ts +0 -123
- package/src/gestures/controllers/index.ts +0 -4
- package/src/gestures/eventAttacher.ts +0 -67
- package/src/gestures/hooks/index.ts +0 -5
- package/src/gestures/hooks/useDrag.ts +0 -14
- package/src/gestures/hooks/useGesture.ts +0 -38
- package/src/gestures/hooks/useMouseMove.ts +0 -11
- package/src/gestures/hooks/useRecognizer.ts +0 -59
- package/src/gestures/hooks/useScroll.ts +0 -11
- package/src/gestures/hooks/useWheel.ts +0 -11
- package/src/gestures/index.ts +0 -2
- package/src/gestures/math.ts +0 -120
- package/src/gestures/types.ts +0 -49
- package/src/gestures/withDefault.ts +0 -3
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useMeasure.ts +0 -133
- package/src/hooks/useOutsideClick.ts +0 -36
- package/src/hooks/useWindowDimension.ts +0 -59
- package/src/index.ts +0 -5
- package/src/utils/delay.ts +0 -9
- package/src/utils/index.ts +0 -2
- package/src/utils/isDefined.ts +0 -4
- package/tsconfig.json +0 -25
|
@@ -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,15 @@
|
|
|
1
|
+
export declare const AnimationConfigUtils: {
|
|
2
|
+
ELASTIC: import("../core").FluidValueConfig;
|
|
3
|
+
BOUNCE: import("../core").FluidValueConfig;
|
|
4
|
+
EASE: import("../core").FluidValueConfig;
|
|
5
|
+
STIFF: import("../core").FluidValueConfig;
|
|
6
|
+
WOOBLE: import("../core").FluidValueConfig;
|
|
7
|
+
EASE_IN: import("../core").FluidValueConfig;
|
|
8
|
+
EASE_OUT: import("../core").FluidValueConfig;
|
|
9
|
+
EASE_IN_OUT: import("../core").FluidValueConfig;
|
|
10
|
+
POWER1: import("../core").FluidValueConfig;
|
|
11
|
+
POWER2: import("../core").FluidValueConfig;
|
|
12
|
+
POWER3: import("../core").FluidValueConfig;
|
|
13
|
+
POWER4: import("../core").FluidValueConfig;
|
|
14
|
+
LINEAR: import("../core").FluidValueConfig;
|
|
15
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { FluidValueConfig } from '../core';
|
|
2
|
+
export type InitialConfigType = 'linear' | 'easein' | 'easeout' | 'easeinout' | 'ease' | 'power1' | 'power2' | 'power3' | 'power4' | 'elastic' | 'stiff' | 'wooble' | 'bounce';
|
|
3
|
+
export declare const getInitialConfig: (animationType?: InitialConfigType) => FluidValueConfig;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { interpolate, bInterpolate } from './interpolation';
|
|
2
|
+
export { AnimatedBlock, AnimatedImage, AnimatedInline, MountedBlock, ScrollableBlock, TransitionBlock, } from './modules';
|
|
3
|
+
export { useAnimatedValue, UseAnimatedValueConfig } from './useAnimatedValue';
|
|
4
|
+
export { useMountedValue } from './useMountedValue';
|
|
5
|
+
export { AnimationConfigUtils } from './animationType';
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { ExtrapolateConfig, FluidValue } from '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export declare function bInterpolate(value: number | FluidValue | ValueType, minOutput: number | string, maxOutput: number | string, extrapolateConfig?: ExtrapolateConfig): any;
|
|
1
|
+
import { ExtrapolateConfig, FluidValue } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* interpolate functions maps input range to given output range
|
|
4
|
+
* @param value - number | TransitionValue
|
|
5
|
+
* @param inputRange - Array<number>
|
|
6
|
+
* @param outputRange - Array<number | string>
|
|
7
|
+
* @param extrapolateConfig - "clamp" | "identity" | "extend"
|
|
8
|
+
* @returns - number | TransitionValue
|
|
9
|
+
*/
|
|
10
|
+
export declare function interpolate(value: number | FluidValue, inputRange: Array<number>, outputRange: Array<number | string>, extrapolateConfig?: ExtrapolateConfig): any;
|
|
11
|
+
/**
|
|
12
|
+
* bInterpolate functions maps input range [0, 1] to given [minOutput, maxOutput]
|
|
13
|
+
* sorthand function to interpolate input range [0, 1]
|
|
14
|
+
* @param value - number | TransitionValue
|
|
15
|
+
* @param minOutput - number | string
|
|
16
|
+
* @param maxOutput - number | string
|
|
17
|
+
* @param extrapolateConfig - "clamp" | "identity" | "extend"
|
|
18
|
+
* @returns - number | TransitionValue
|
|
19
|
+
*/
|
|
20
|
+
export declare function bInterpolate(value: number | FluidValue, minOutput: number | string, maxOutput: number | string, extrapolateConfig?: ExtrapolateConfig): any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnimatedBlock - A higher order component built upon `div` element
|
|
3
|
+
* which can accept `AnimatedValue`. It also exposes some extra style properties like
|
|
4
|
+
* translateX, translateY, rotateX, rotateY, scaleX, etc.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AnimatedBlock: import("react").ForwardRefExoticComponent<Omit<import("../../core/types/fluid").FluidHTMLAttributes<"div"> & import("../../core/types/fluid").FluidSVGAttributes<"div">, "style"> & {
|
|
7
|
+
style?: import("../../core/types/fluid").FluidCSSProperties;
|
|
8
|
+
} & import("react").RefAttributes<unknown>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnimatedImage - A higher order component built upon `img` element
|
|
3
|
+
* which can accept `AnimatedValue`. It also exposes some extra style properties like
|
|
4
|
+
* translateX, translateY, rotateX, rotateY, scaleX, etc.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AnimatedImage: import("react").ForwardRefExoticComponent<Omit<import("../../core/types/fluid").FluidHTMLAttributes<"img"> & import("../../core/types/fluid").FluidSVGAttributes<"img">, "style"> & {
|
|
7
|
+
style?: import("../../core/types/fluid").FluidCSSProperties;
|
|
8
|
+
} & import("react").RefAttributes<unknown>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnimatedInline - A higher order component built upon `span` element
|
|
3
|
+
* which can accept `AnimatedValue`. It also exposes some extra style properties like
|
|
4
|
+
* translateX, translateY, rotateX, rotateY, scaleX, etc.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AnimatedInline: import("react").ForwardRefExoticComponent<Omit<import("../../core/types/fluid").FluidHTMLAttributes<"span"> & import("../../core/types/fluid").FluidSVGAttributes<"span">, "style"> & {
|
|
7
|
+
style?: import("../../core/types/fluid").FluidCSSProperties;
|
|
8
|
+
} & import("react").RefAttributes<unknown>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FluidValue, FluidValueConfig } from '../../core';
|
|
3
|
+
interface MountedValueConfig extends FluidValueConfig {
|
|
4
|
+
}
|
|
5
|
+
interface MountedBlockProps {
|
|
6
|
+
state: boolean;
|
|
7
|
+
children: (animation: {
|
|
8
|
+
value: FluidValue;
|
|
9
|
+
}) => React.ReactNode;
|
|
10
|
+
from?: number;
|
|
11
|
+
enter?: number;
|
|
12
|
+
exit?: number;
|
|
13
|
+
config?: MountedValueConfig;
|
|
14
|
+
enterConfig?: MountedValueConfig;
|
|
15
|
+
exitConfig?: MountedValueConfig;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* MountedBlock - Higher order component which handles mounting and unmounting of a component.
|
|
19
|
+
* @prop { boolean } state - Boolean indicating the component should mount or unmount.
|
|
20
|
+
* @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
|
|
21
|
+
* @prop { number } from - Number that dictates the beginning state for animation.
|
|
22
|
+
* @prop { number } enter - Number that dictates the entry state for animation.
|
|
23
|
+
* @prop { number } exit - Number that dictates the exit state for animation.
|
|
24
|
+
* @prop { MountedValueConfig } config - Animation configuration for overall animation.
|
|
25
|
+
* @prop { MountedValueConfig } enterConfig - Animation configuration for the entering state of animation.
|
|
26
|
+
* @prop { MountedValueConfig } exitConfig - Animation configuration for the entering state of animation.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MountedBlock: ({ state, children, from, enter, exit, config, enterConfig, exitConfig, }: MountedBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { UseAnimatedValueConfig
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @prop {
|
|
17
|
-
* @prop {
|
|
18
|
-
* @prop {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UseAnimatedValueConfig } from '../useAnimatedValue';
|
|
3
|
+
import { FluidValue } from '../../core';
|
|
4
|
+
interface ScrollableBlockProps {
|
|
5
|
+
children?: (animation: {
|
|
6
|
+
value?: FluidValue | string | number;
|
|
7
|
+
}) => React.ReactNode;
|
|
8
|
+
direction?: 'single' | 'both';
|
|
9
|
+
threshold?: number;
|
|
10
|
+
animationConfig?: UseAnimatedValueConfig;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ScrollableBlock - Higher order component to handle the entrance or exit animation
|
|
14
|
+
* of a component when it enters or exit the viewport. Accepts child as a function with
|
|
15
|
+
* `AnimatedValue` as its first argument which can be interpolated on input range [0, 1]
|
|
16
|
+
* @prop { function } children - child as a function with `AnimatedValue` as its first argument.
|
|
17
|
+
* @prop { 'single' | 'both' } direction - single applies animation on enter once, both applies on enter and exit.
|
|
18
|
+
* @prop { number } threshold - should be in range 0 to 1 which equivalent to `IntersectionObserver` threshold.
|
|
19
|
+
* @prop { UseAnimatedValueConfig } animationConfig - Animation config
|
|
20
|
+
*/
|
|
21
|
+
export declare const ScrollableBlock: (props: ScrollableBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { UseAnimatedValueConfig
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* @prop {
|
|
14
|
-
* @prop {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export {};
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UseAnimatedValueConfig } from '../useAnimatedValue';
|
|
3
|
+
import { FluidValue } from '../../core';
|
|
4
|
+
interface TransitionBlockProps {
|
|
5
|
+
state: boolean;
|
|
6
|
+
children: (animation: {
|
|
7
|
+
value?: FluidValue | string | number;
|
|
8
|
+
}) => React.ReactNode;
|
|
9
|
+
config?: UseAnimatedValueConfig;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* TransitionBlock - Higher order component which animates on state change.
|
|
13
|
+
* @prop { boolean } state - Boolean indicating the current state of animation, usually `false = 0 and true = 1`.
|
|
14
|
+
* @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
|
|
15
|
+
* @prop { UseAnimatedValueConfig } config - Animation configuration.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TransitionBlock: ({ state, children, config, }: TransitionBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './AnimatedBlock';
|
|
2
|
-
export * from './AnimatedInline';
|
|
3
|
-
export * from './AnimatedImage';
|
|
4
|
-
export * from './MountedBlock';
|
|
5
|
-
export * from './ScrollableBlock';
|
|
6
|
-
export * from './TransitionBlock';
|
|
1
|
+
export * from './AnimatedBlock';
|
|
2
|
+
export * from './AnimatedInline';
|
|
3
|
+
export * from './AnimatedImage';
|
|
4
|
+
export * from './MountedBlock';
|
|
5
|
+
export * from './ScrollableBlock';
|
|
6
|
+
export * from './TransitionBlock';
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface UseAnimatedValueConfig extends
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export declare function useAnimatedValue(initialValue: Length, config?: UseAnimatedValueConfig): {
|
|
19
|
-
value: ValueType;
|
|
20
|
-
currentValue: number | string;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
1
|
+
import { FluidValueConfig, FluidValue } from '../core';
|
|
2
|
+
type Length = number | string;
|
|
3
|
+
export interface UseAnimatedValueConfig extends FluidValueConfig {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* `useAnimatedValue` returns an animation value with `.value` and `.currentValue` property which is
|
|
7
|
+
* initialized when passed to argument (`initialValue`). The retured value persist until the lifetime of
|
|
8
|
+
* a component. It doesnot cast any re-renders which can is very good for performance optimization.
|
|
9
|
+
*
|
|
10
|
+
* @param { string | number } initialValue - Initial value
|
|
11
|
+
* @param { UseAnimatedValueConfig } config - Animation configuration object.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useAnimatedValue(initialValue: Length, config?: UseAnimatedValueConfig): {
|
|
14
|
+
value: FluidValue | string | number | undefined;
|
|
15
|
+
currentValue: number | string;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, mounted: boolean) => React.ReactNode) => any;
|
|
1
|
+
import { UseMountConfig, FluidValue } from '../core';
|
|
2
|
+
export interface UseMountedValueConfig extends UseMountConfig {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* `useMountedValue` handles mounting and unmounting of a component which captures current state
|
|
6
|
+
* passed as an arugment (`state`) and exposes the shadow state which handles the mount and unmount
|
|
7
|
+
* of a component.
|
|
8
|
+
*
|
|
9
|
+
* @param { boolean } state - Boolean indicating the component should mount or unmount.
|
|
10
|
+
* @param { UseMountedValueConfig } config - Animation configuration.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useMountedValue(state: boolean, config: UseMountedValueConfig): (cb: (value: {
|
|
13
|
+
value: FluidValue;
|
|
14
|
+
}, mounted: boolean) => React.ReactNode) => import("react").ReactNode;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare class DragGesture extends Gesture {
|
|
4
|
-
movementStart: Vector2;
|
|
5
|
-
initialMovement: Vector2;
|
|
6
|
-
movement: Vector2;
|
|
7
|
-
previousMovement: Vector2;
|
|
8
|
-
translation: Vector2;
|
|
9
|
-
offset: Vector2;
|
|
10
|
-
velocity: Vector2;
|
|
11
|
-
_initEvents(): void;
|
|
12
|
-
_cancelEvents(): void;
|
|
13
|
-
_handleCallback(): void;
|
|
14
|
-
pointerDown(e: any): void;
|
|
15
|
-
pointerMove(e: any): void;
|
|
16
|
-
pointerUp(): void;
|
|
17
|
-
}
|
|
1
|
+
import { Gesture } from './Gesture';
|
|
2
|
+
import type { Vector2 } from '../types';
|
|
3
|
+
export declare class DragGesture extends Gesture {
|
|
4
|
+
movementStart: Vector2;
|
|
5
|
+
initialMovement: Vector2;
|
|
6
|
+
movement: Vector2;
|
|
7
|
+
previousMovement: Vector2;
|
|
8
|
+
translation: Vector2;
|
|
9
|
+
offset: Vector2;
|
|
10
|
+
velocity: Vector2;
|
|
11
|
+
_initEvents(): void;
|
|
12
|
+
_cancelEvents(): void;
|
|
13
|
+
_handleCallback(): void;
|
|
14
|
+
pointerDown(e: any): void;
|
|
15
|
+
pointerMove(e: any): void;
|
|
16
|
+
pointerUp(): void;
|
|
17
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export declare class Gesture {
|
|
2
|
-
currentIndex?: number;
|
|
3
|
-
lastTimeStamp: number;
|
|
4
|
-
isActive: boolean;
|
|
5
|
-
targetElement?: HTMLElement;
|
|
6
|
-
targetElements: Array<HTMLElement>;
|
|
7
|
-
config?: any;
|
|
8
|
-
callback?: <T>(event: T) => void;
|
|
9
|
-
_subscribe?: (eventKeys?: Array<string>) => void;
|
|
10
|
-
static _VELOCITY_LIMIT: number;
|
|
11
|
-
_initEvents(): void;
|
|
12
|
-
_cancelEvents(): void;
|
|
13
|
-
applyCallback(callback: <T>(event: T) => void): void;
|
|
14
|
-
applyGesture({ targetElement, targetElements, callback, config, }: {
|
|
15
|
-
targetElement?: any;
|
|
16
|
-
targetElements?: any;
|
|
17
|
-
callback: <T>(event: T) => void;
|
|
18
|
-
config?: any;
|
|
19
|
-
}): () => void | undefined;
|
|
20
|
-
}
|
|
1
|
+
export declare class Gesture {
|
|
2
|
+
currentIndex?: number;
|
|
3
|
+
lastTimeStamp: number;
|
|
4
|
+
isActive: boolean;
|
|
5
|
+
targetElement?: HTMLElement;
|
|
6
|
+
targetElements: Array<HTMLElement>;
|
|
7
|
+
config?: any;
|
|
8
|
+
callback?: <T>(event: T) => void;
|
|
9
|
+
_subscribe?: (eventKeys?: Array<string>) => void;
|
|
10
|
+
static _VELOCITY_LIMIT: number;
|
|
11
|
+
_initEvents(): void;
|
|
12
|
+
_cancelEvents(): void;
|
|
13
|
+
applyCallback(callback: <T>(event: T) => void): void;
|
|
14
|
+
applyGesture({ targetElement, targetElements, callback, config, }: {
|
|
15
|
+
targetElement?: any;
|
|
16
|
+
targetElements?: any;
|
|
17
|
+
callback: <T>(event: T) => void;
|
|
18
|
+
config?: any;
|
|
19
|
+
}): () => void | undefined;
|
|
20
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Vector2 } from '../types';
|
|
2
|
-
import { Gesture } from './Gesture';
|
|
3
|
-
export declare class MouseMoveGesture extends Gesture {
|
|
4
|
-
event?: MouseEvent;
|
|
5
|
-
isActiveID?: any;
|
|
6
|
-
movement: Vector2;
|
|
7
|
-
previousMovement: Vector2;
|
|
8
|
-
velocity: Vector2;
|
|
9
|
-
direction: Vector2;
|
|
10
|
-
_initEvents(): void;
|
|
11
|
-
_handleCallback(): void;
|
|
12
|
-
onMouseMove(e: MouseEvent): void;
|
|
13
|
-
}
|
|
1
|
+
import { Vector2 } from '../types';
|
|
2
|
+
import { Gesture } from './Gesture';
|
|
3
|
+
export declare class MouseMoveGesture extends Gesture {
|
|
4
|
+
event?: MouseEvent;
|
|
5
|
+
isActiveID?: any;
|
|
6
|
+
movement: Vector2;
|
|
7
|
+
previousMovement: Vector2;
|
|
8
|
+
velocity: Vector2;
|
|
9
|
+
direction: Vector2;
|
|
10
|
+
_initEvents(): void;
|
|
11
|
+
_handleCallback(): void;
|
|
12
|
+
onMouseMove(e: MouseEvent): void;
|
|
13
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Vector2 } from '../types';
|
|
2
|
-
import { Gesture } from './Gesture';
|
|
3
|
-
export declare class ScrollGesture extends Gesture {
|
|
4
|
-
isActiveID?: any;
|
|
5
|
-
movement: Vector2;
|
|
6
|
-
previousMovement: Vector2;
|
|
7
|
-
direction: Vector2;
|
|
8
|
-
velocity: Vector2;
|
|
9
|
-
_initEvents(): void;
|
|
10
|
-
_handleCallback(): void;
|
|
11
|
-
onScroll({ x, y }: Vector2): void;
|
|
12
|
-
scrollListener(): void;
|
|
13
|
-
scrollElementListener(): void;
|
|
14
|
-
}
|
|
1
|
+
import { Vector2 } from '../types';
|
|
2
|
+
import { Gesture } from './Gesture';
|
|
3
|
+
export declare class ScrollGesture extends Gesture {
|
|
4
|
+
isActiveID?: any;
|
|
5
|
+
movement: Vector2;
|
|
6
|
+
previousMovement: Vector2;
|
|
7
|
+
direction: Vector2;
|
|
8
|
+
velocity: Vector2;
|
|
9
|
+
_initEvents(): void;
|
|
10
|
+
_handleCallback(): void;
|
|
11
|
+
onScroll({ x, y }: Vector2): void;
|
|
12
|
+
scrollListener(): void;
|
|
13
|
+
scrollElementListener(): void;
|
|
14
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Vector2 } from '../types';
|
|
2
|
-
import { Gesture } from './Gesture';
|
|
3
|
-
export declare class WheelGesture extends Gesture {
|
|
4
|
-
isActiveID?: any;
|
|
5
|
-
movement: Vector2;
|
|
6
|
-
previousMovement: Vector2;
|
|
7
|
-
direction: Vector2;
|
|
8
|
-
velocity: Vector2;
|
|
9
|
-
delta: Vector2;
|
|
10
|
-
offset: Vector2;
|
|
11
|
-
translation: Vector2;
|
|
12
|
-
_initEvents(): void;
|
|
13
|
-
_handleCallback(): void;
|
|
14
|
-
onWheel(event: WheelEvent): void;
|
|
15
|
-
}
|
|
1
|
+
import { Vector2 } from '../types';
|
|
2
|
+
import { Gesture } from './Gesture';
|
|
3
|
+
export declare class WheelGesture extends Gesture {
|
|
4
|
+
isActiveID?: any;
|
|
5
|
+
movement: Vector2;
|
|
6
|
+
previousMovement: Vector2;
|
|
7
|
+
direction: Vector2;
|
|
8
|
+
velocity: Vector2;
|
|
9
|
+
delta: Vector2;
|
|
10
|
+
offset: Vector2;
|
|
11
|
+
translation: Vector2;
|
|
12
|
+
_initEvents(): void;
|
|
13
|
+
_handleCallback(): void;
|
|
14
|
+
onWheel(event: WheelEvent): void;
|
|
15
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './DragGesture';
|
|
2
|
-
export * from './MouseMoveGesture';
|
|
3
|
-
export * from './ScrollGesture';
|
|
4
|
-
export * from './WheelGesture';
|
|
1
|
+
export * from './DragGesture';
|
|
2
|
+
export * from './MouseMoveGesture';
|
|
3
|
+
export * from './ScrollGesture';
|
|
4
|
+
export * from './WheelGesture';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type MouseEventType = 'click' | 'dblclick' | 'mousedown' | 'mousemove' | 'mouseup' | 'touchstart' | 'touchmove' | 'touchend' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'mouseover' | 'scroll' | 'wheel' | 'contextmenu';
|
|
2
|
+
type DomTargetTypes = Array<Window | Document | HTMLElement>;
|
|
3
|
+
/**
|
|
4
|
+
* Attach multiple document / window event / HTMLElement
|
|
5
|
+
*/
|
|
6
|
+
export declare function attachEvents(domTargets: DomTargetTypes, events: Array<[
|
|
7
|
+
event: MouseEventType,
|
|
8
|
+
callback: (e: any) => void,
|
|
9
|
+
capture?: any
|
|
10
|
+
]>): (eventKeys?: Array<string>) => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './math';
|