react-ui-animate 3.3.2 → 4.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/LICENSE +21 -21
- package/README.md +209 -209
- package/dist/animation/animationType.d.ts +14 -14
- package/dist/animation/core/FluidArrayController.d.ts +7 -0
- package/dist/animation/core/FluidController.d.ts +32 -0
- package/dist/animation/core/inerpolate.d.ts +9 -0
- package/dist/animation/core/useFluidValue.d.ts +3 -0
- package/dist/animation/core/useMount.d.ts +18 -0
- package/dist/animation/index.d.ts +1 -1
- package/dist/animation/interpolation.d.ts +3 -4
- package/dist/animation/modules/MountedBlock.d.ts +6 -13
- package/dist/animation/modules/ScrollableBlock.d.ts +2 -2
- package/dist/animation/modules/TransitionBlock.d.ts +2 -2
- package/dist/animation/modules/index.d.ts +0 -3
- package/dist/animation/useAnimatedValue.d.ts +9 -10
- package/dist/animation/useMountedValue.d.ts +4 -3
- package/dist/animation/withFunctions.d.ts +55 -48
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +52 -52
- 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
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface UseAnimatedValueConfig extends FluidValueConfig {
|
|
1
|
+
import type { UseFluidValueConfig } from './core/FluidController';
|
|
2
|
+
export interface UseAnimatedValueConfig extends UseFluidValueConfig {
|
|
4
3
|
}
|
|
5
4
|
type AssignValue = {
|
|
6
|
-
toValue?:
|
|
5
|
+
toValue?: number;
|
|
7
6
|
config?: UseAnimatedValueConfig;
|
|
8
7
|
};
|
|
9
|
-
export type
|
|
8
|
+
export type UpdateValue = AssignValue | ((update: (next: AssignValue) => Promise<any>) => void);
|
|
10
9
|
/**
|
|
11
10
|
* `useAnimatedValue` returns an animation value with `.value` and `.currentValue` property which is
|
|
12
|
-
* initialized when passed to argument (`initialValue`). The
|
|
13
|
-
* a component. It
|
|
11
|
+
* initialized when passed to argument (`initialValue`). The returned value persist until the lifetime of
|
|
12
|
+
* a component. It doesn't cast any re-renders which can is very good for performance optimization.
|
|
14
13
|
*
|
|
15
14
|
* @param { string | number } initialValue - Initial value
|
|
16
15
|
* @param { UseAnimatedValueConfig } config - Animation configuration object.
|
|
17
16
|
*/
|
|
18
|
-
export declare function useAnimatedValue(initialValue:
|
|
19
|
-
value:
|
|
20
|
-
currentValue: number
|
|
17
|
+
export declare function useAnimatedValue<T extends number | number[]>(initialValue: T, config?: UseAnimatedValueConfig): {
|
|
18
|
+
value: T extends number ? any : any[];
|
|
19
|
+
currentValue: T extends number ? number : number[];
|
|
21
20
|
};
|
|
22
21
|
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FluidValue } from '@raidipesh78/re-motion';
|
|
2
|
+
import { UseMountConfig } from './core/useMount';
|
|
2
3
|
export interface UseMountedValueConfig extends UseMountConfig {
|
|
3
4
|
}
|
|
4
5
|
/**
|
|
5
6
|
* `useMountedValue` handles mounting and unmounting of a component which captures current state
|
|
6
|
-
* passed as an
|
|
7
|
+
* passed as an argument (`state`) and exposes the shadow state which handles the mount and unmount
|
|
7
8
|
* of a component.
|
|
8
9
|
*
|
|
9
10
|
* @param { boolean } state - Boolean indicating the component should mount or unmount.
|
|
10
|
-
* @param {
|
|
11
|
+
* @param { UseAnimatedValueConfig } config - Animation configuration.
|
|
11
12
|
*/
|
|
12
13
|
export declare function useMountedValue(state: boolean, config: UseMountedValueConfig): (cb: (value: {
|
|
13
14
|
value: FluidValue;
|
|
@@ -1,83 +1,90 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
interface WithOnCallbacks extends Pick<
|
|
3
|
-
}
|
|
4
|
-
interface WithEaseConfig extends WithOnCallbacks {
|
|
5
|
-
}
|
|
6
|
-
interface WithSpringConfig extends Pick<FluidValueConfig, 'mass' | 'friction' | 'tension'>, WithOnCallbacks {
|
|
7
|
-
}
|
|
8
|
-
interface WithTimingConfig extends Pick<FluidValueConfig, 'duration' | 'easing'>, WithOnCallbacks {
|
|
9
|
-
}
|
|
10
|
-
interface WithDecayConfig extends Pick<FluidValueConfig, 'decay' | 'velocity' | 'deceleration'>, WithOnCallbacks {
|
|
1
|
+
import type { UseAnimatedValueConfig } from './useAnimatedValue';
|
|
2
|
+
interface WithOnCallbacks extends Pick<UseAnimatedValueConfig, 'onRest' | 'onStart' | 'onChange'> {
|
|
11
3
|
}
|
|
12
4
|
/**
|
|
13
5
|
* Creates a default animation configuration.
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
16
|
-
* @returns {{ toValue:
|
|
6
|
+
* @param {number} toValue - The target value of the animation.
|
|
7
|
+
* @param {UseAnimatedValueConfig} config - Optional configuration.
|
|
8
|
+
* @returns {{ toValue: number; config: UseAnimatedValueConfig }}
|
|
17
9
|
*/
|
|
18
|
-
export declare const withConfig: (toValue:
|
|
19
|
-
toValue:
|
|
20
|
-
config:
|
|
10
|
+
export declare const withConfig: (toValue: number, config?: UseAnimatedValueConfig) => {
|
|
11
|
+
toValue: number;
|
|
12
|
+
config: UseAnimatedValueConfig | undefined;
|
|
21
13
|
};
|
|
14
|
+
interface WithEaseConfig extends WithOnCallbacks {
|
|
15
|
+
}
|
|
22
16
|
/**
|
|
23
17
|
* Creates an ease animation configuration.
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {
|
|
26
|
-
* @returns {{ toValue:
|
|
18
|
+
* @param {number} toValue - The target value of the animation.
|
|
19
|
+
* @param {UseAnimatedValueConfig} [config=AnimationConfigUtils.EASE] - Optional ease configuration.
|
|
20
|
+
* @returns {{ toValue: number; config: UseAnimatedValueConfig }}
|
|
27
21
|
*/
|
|
28
|
-
export declare const withEase: (toValue:
|
|
29
|
-
toValue:
|
|
30
|
-
config:
|
|
22
|
+
export declare const withEase: (toValue: number, config?: WithEaseConfig) => {
|
|
23
|
+
toValue: number;
|
|
24
|
+
config: UseAnimatedValueConfig | undefined;
|
|
31
25
|
};
|
|
26
|
+
interface WithSpringConfig extends Pick<UseAnimatedValueConfig, 'mass' | 'friction' | 'tension'>, WithOnCallbacks {
|
|
27
|
+
}
|
|
32
28
|
/**
|
|
33
29
|
* Creates a spring animation configuration.
|
|
34
|
-
* @param {
|
|
30
|
+
* @param {number} toValue - The target value of the animation.
|
|
35
31
|
* @param {WithSpringConfig} [config=AnimationConfigUtils.ELASTIC] - Optional spring configuration.
|
|
36
|
-
* @returns {{ toValue:
|
|
32
|
+
* @returns {{ toValue: number; config: WithSpringConfig }}
|
|
37
33
|
*/
|
|
38
|
-
export declare const withSpring: (toValue:
|
|
39
|
-
toValue:
|
|
40
|
-
config:
|
|
34
|
+
export declare const withSpring: (toValue: number, config?: WithSpringConfig) => {
|
|
35
|
+
toValue: number;
|
|
36
|
+
config: UseAnimatedValueConfig | undefined;
|
|
41
37
|
};
|
|
38
|
+
interface WithTimingConfig extends Pick<UseAnimatedValueConfig, 'duration' | 'easing'>, WithOnCallbacks {
|
|
39
|
+
}
|
|
42
40
|
/**
|
|
43
41
|
* Creates a timing animation configuration.
|
|
44
|
-
* @param {
|
|
42
|
+
* @param {number} toValue - The target value of the animation.
|
|
45
43
|
* @param {WithTimingConfig} [config={ duration: 250 }] - Optional timing configuration.
|
|
46
|
-
* @returns {{ toValue:
|
|
44
|
+
* @returns {{ toValue: number; config: WithTimingConfig }}
|
|
47
45
|
*/
|
|
48
|
-
export declare const withTiming: (toValue:
|
|
49
|
-
toValue:
|
|
50
|
-
config:
|
|
46
|
+
export declare const withTiming: (toValue: number, config?: WithTimingConfig) => {
|
|
47
|
+
toValue: number;
|
|
48
|
+
config: UseAnimatedValueConfig | undefined;
|
|
51
49
|
};
|
|
50
|
+
interface WithDecayConfig extends Pick<UseAnimatedValueConfig, 'velocity' | 'deceleration'>, WithOnCallbacks {
|
|
51
|
+
}
|
|
52
52
|
/**
|
|
53
53
|
* Creates a decay animation configuration.
|
|
54
54
|
* @param {WithDecayConfig} config - Optional decay configuration.
|
|
55
55
|
* @returns {{ config: WithDecayConfig }}
|
|
56
56
|
*/
|
|
57
|
-
export declare const withDecay: (config
|
|
58
|
-
config:
|
|
57
|
+
export declare const withDecay: (config?: WithDecayConfig) => {
|
|
58
|
+
config: {
|
|
59
|
+
velocity?: number;
|
|
60
|
+
deceleration?: number;
|
|
61
|
+
onRest?: (value: number) => void;
|
|
62
|
+
onStart?: (value: number) => void;
|
|
63
|
+
onChange?: (value: number) => void;
|
|
64
|
+
decay: boolean;
|
|
65
|
+
};
|
|
59
66
|
};
|
|
60
67
|
/**
|
|
61
68
|
* Creates a sequence of animations that run one after another.
|
|
62
|
-
* @param {Array<{ toValue:
|
|
69
|
+
* @param {Array<{ toValue: number; config?: UseAnimatedValueConfig } | number>} configs - An array of animation configurations or delays.
|
|
63
70
|
* @returns {Function} An async function that runs the animations in sequence.
|
|
64
71
|
*/
|
|
65
72
|
export declare const withSequence: (configs: Array<{
|
|
66
|
-
toValue?:
|
|
67
|
-
config?:
|
|
73
|
+
toValue?: number;
|
|
74
|
+
config?: UseAnimatedValueConfig;
|
|
68
75
|
} | number>) => (next: (arg: {
|
|
69
|
-
toValue?:
|
|
70
|
-
config?:
|
|
76
|
+
toValue?: number;
|
|
77
|
+
config?: UseAnimatedValueConfig;
|
|
71
78
|
}) => void) => Promise<void>;
|
|
72
79
|
/**
|
|
73
80
|
* Adds a delay before the given animation.
|
|
74
81
|
* @param {number} delay - The delay in milliseconds.
|
|
75
|
-
* @param {{ toValue:
|
|
76
|
-
* @returns {{ toValue:
|
|
82
|
+
* @param {{ toValue: number; config?: UseAnimatedValueConfig }} animation - The animation configuration (withTiming | withSpring).
|
|
83
|
+
* @returns {{ toValue: number; config: UseAnimatedValueConfig }} The updated animation configuration with delay.
|
|
77
84
|
*/
|
|
78
85
|
export declare const withDelay: (delay: number, animation: {
|
|
79
|
-
toValue:
|
|
80
|
-
config?:
|
|
86
|
+
toValue: number;
|
|
87
|
+
config?: UseAnimatedValueConfig;
|
|
81
88
|
}) => {
|
|
82
89
|
config: {
|
|
83
90
|
delay: number;
|
|
@@ -85,16 +92,16 @@ export declare const withDelay: (delay: number, animation: {
|
|
|
85
92
|
tension?: number;
|
|
86
93
|
friction?: number;
|
|
87
94
|
duration?: number;
|
|
88
|
-
easing?:
|
|
95
|
+
easing?: (value: number) => number;
|
|
89
96
|
immediate?: boolean;
|
|
90
97
|
restDistance?: number;
|
|
91
|
-
onChange?:
|
|
92
|
-
onRest?:
|
|
93
|
-
onStart?:
|
|
98
|
+
onChange?: (value: number) => void;
|
|
99
|
+
onRest?: (value: number) => void;
|
|
100
|
+
onStart?: (value: number) => void;
|
|
94
101
|
decay?: boolean;
|
|
95
102
|
velocity?: number;
|
|
96
103
|
deceleration?: number;
|
|
97
104
|
};
|
|
98
|
-
toValue:
|
|
105
|
+
toValue: number;
|
|
99
106
|
};
|
|
100
107
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Easing, makeFluid as makeAnimated, fluid as animate, } from '@raidipesh78/re-motion';
|
|
2
|
-
export {
|
|
2
|
+
export { AnimationConfigUtils, MountedBlock, ScrollableBlock, TransitionBlock, } from './animation';
|
|
3
3
|
export { bInterpolate, interpolate } from './animation';
|
|
4
4
|
export { useAnimatedValue, useMountedValue } from './animation';
|
|
5
5
|
export { withSpring, withTiming, withSequence, withDelay, withEase, withConfig, withDecay, delay, } from './animation';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t=require("@raidipesh78/re-motion"),e=require("react/jsx-runtime"),n=require("react");function i(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var r=i(n),o=function(t){return null!=t};function s(e){if(!o(e)||"number"!=typeof e&&!t.isFluidValue(e))throw console.log(e),new Error("Invalid ".concat(e," type for interpolate function. Expected number or FluidValue."));return e}var u=t.makeFluid("div"),c=t.makeFluid("span"),a=t.makeFluid("img");function l(e,n){var i=t.useMount(e,n);return function(t){return i((function(e,n){return t({value:e},n)}))}}var h=function(t,e){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},h(t,e)};function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var v=function(){return v=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},v.apply(this,arguments)};function m(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function u(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}c((i=i.apply(t,e||[])).next())}))}function p(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&u[0]?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,i=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=e.call(t,s)}catch(t){u=[6,t],i=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function y(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function x(t,e,n){if(n||2===arguments.length)for(var i,r=0,o=e.length;r<o;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var b=function(e){switch(e){case"elastic":return{mass:1,friction:18,tension:250};case"stiff":return{mass:1,friction:18,tension:350};case"wooble":return{mass:1,friction:8,tension:250};case"bounce":return{duration:500,easing:t.Easing.bounce};case"power1":return{duration:500,easing:t.Easing.bezier(.17,.42,.51,.97)};case"power2":return{duration:500,easing:t.Easing.bezier(.07,.11,.13,1)};case"power3":return{duration:500,easing:t.Easing.bezier(.09,.7,.16,1.04)};case"power4":return{duration:500,easing:t.Easing.bezier(.05,.54,0,1.03)};case"linear":return{duration:500,easing:t.Easing.linear};case"easein":return{duration:500,easing:t.Easing.in(t.Easing.ease)};case"easeout":return{duration:500,easing:t.Easing.out(t.Easing.ease)};case"easeinout":return{duration:500,easing:t.Easing.inOut(t.Easing.ease)};default:return{mass:1,friction:34,tension:290}}},g={ELASTIC:b("elastic"),BOUNCE:b("bounce"),EASE:b("ease"),STIFF:b("stiff"),WOOBLE:b("wooble"),EASE_IN:b("easein"),EASE_OUT:b("easeout"),EASE_IN_OUT:b("easeinout"),POWER1:b("power1"),POWER2:b("power2"),POWER3:b("power3"),POWER4:b("power4"),LINEAR:b("linear")};function E(e,n){var i=d(t.useFluidValue(e,v(v({},g.EASE),n)),2),r=i[0],o=i[1],s={value:r,currentValue:r.get()};return new Proxy(s,{set:function(t,e,n){if("value"===e)return"number"==typeof n||"string"==typeof n?queueMicrotask((function(){return o({toValue:n})})):"object"!=typeof n&&"function"!=typeof n||queueMicrotask((function(){return o(n)})),!0;throw new Error("You cannot set any other property to animation node.")},get:function(t,e){if("value"===e)return r;if("currentValue"===e)return r.get();throw new Error("You cannot access any other property from animation node.")}})}function w(t){return t?1:0}function M(t,e,n){return Math.min(Math.max(t,e),n)}function _(t,e,n){return 0===e||Math.abs(e)===1/0?function(t,e){return Math.pow(t,5*e)}(t,n):t*e*n/(e+n*t)}var I=function(t,e){return{toValue:t,config:e}};function T(t,e){var n=new Map;return e.forEach((function(e){var i=d(e,3),r=i[0],o=i[1],s=i[2],u=void 0!==s&&s;n.set(r,function(t,e,n,i){return void 0===i&&(i=!1),t.forEach((function(t){t.addEventListener(e,n,i)})),function(){t.forEach((function(t){t.removeEventListener(e,n,i)}))}}(t,r,o,u))})),function(t){var e,i;try{for(var r=y(n.entries()),o=r.next();!o.done;o=r.next()){var s=d(o.value,2),u=s[0],c=s[1];if(!t)return void c();-1!==t.indexOf(u)&&c()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}}var O=function(t,e){return{x:t,y:e}},k=function(){function t(){this.lastTimeStamp=Date.now(),this.isActive=!1,this.targetElements=[]}return t.prototype._initEvents=function(){},t.prototype._cancelEvents=function(){this._subscribe&&this._subscribe()},t.prototype.applyCallback=function(t){this.callback=t},t.prototype.applyGesture=function(t){var e=this,n=t.targetElement,i=t.targetElements,r=t.callback,o=t.config;return this.targetElement=n,this.targetElements=i.map((function(t){return t.current})),this.callback=r,this.config=o,this._initEvents(),function(){return e._subscribe&&e._subscribe()}},t._VELOCITY_LIMIT=20,t}(),L=function(t){function e(){var e=t.apply(this,x([],d(arguments),!1))||this;return e.movementStart=O(0,0),e.initialMovement=O(0,0),e.movement=O(0,0),e.previousMovement=O(0,0),e.translation=O(0,0),e.offset=O(0,0),e.velocity=O(0,0),e}return f(e,t),e.prototype._initEvents=function(){(this.targetElement||this.targetElements.length>0)&&(this._subscribe=T([window],[["mousedown",this.pointerDown.bind(this)],["mousemove",this.pointerMove.bind(this)],["mouseup",this.pointerUp.bind(this)],["touchstart",this.pointerDown.bind(this),{passive:!1}],["touchmove",this.pointerMove.bind(this),{passive:!1}],["touchend",this.pointerUp.bind(this)]]))},e.prototype._cancelEvents=function(){this._subscribe&&this._subscribe(["mousedown","mousemove","touchstart","touchmove"])},e.prototype._handleCallback=function(){var t=this;this.callback&&this.callback({args:[this.currentIndex],down:this.isActive,movementX:this.movement.x,movementY:this.movement.y,offsetX:this.translation.x,offsetY:this.translation.y,velocityX:this.velocity.x,velocityY:this.velocity.y,distanceX:Math.abs(this.movement.x),distanceY:Math.abs(this.movement.y),directionX:Math.sign(this.movement.x),directionY:Math.sign(this.movement.y),cancel:function(){t._cancelEvents()}})},e.prototype.pointerDown=function(t){var e;"touchstart"===t.type?this.movementStart={x:t.touches[0].clientX,y:t.touches[0].clientY}:this.movementStart={x:t.clientX,y:t.clientY},this.movement={x:0,y:0},this.offset={x:this.translation.x,y:this.translation.y},this.previousMovement={x:0,y:0},this.velocity={x:0,y:0};var n=this.targetElements.find((function(e){return e===t.target}));if(t.target===this.targetElement||n){this.isActive=!0,t.preventDefault(),n&&(this.currentIndex=this.targetElements.indexOf(n));var i=(null===(e=this.config)||void 0===e?void 0:e.initial)&&this.config.initial(),r=null==i?void 0:i.movementX,o=null==i?void 0:i.movementY;this.initialMovement={x:null!=r?r:0,y:null!=o?o:0},this.movement={x:this.initialMovement.x,y:this.initialMovement.y},this.previousMovement={x:this.initialMovement.x,y:this.initialMovement.y},this._handleCallback()}},e.prototype.pointerMove=function(t){if(this.isActive){t.preventDefault();var e=Date.now(),n=M(e-this.lastTimeStamp,.1,64);this.lastTimeStamp=e;var i=n/1e3;"touchmove"===t.type?this.movement={x:this.initialMovement.x+(t.touches[0].clientX-this.movementStart.x),y:this.initialMovement.y+(t.touches[0].clientY-this.movementStart.y)}:this.movement={x:this.initialMovement.x+(t.clientX-this.movementStart.x),y:this.initialMovement.y+(t.clientY-this.movementStart.y)},this.translation={x:this.offset.x+this.movement.x,y:this.offset.y+this.movement.y},this.velocity={x:M((this.movement.x-this.previousMovement.x)/i/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT),y:M((this.movement.y-this.previousMovement.y)/i/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()}},e.prototype.pointerUp=function(){this.isActive&&(this.isActive=!1,this._handleCallback(),this._cancelEvents(),this._initEvents())},e}(k),Y=function(t){function e(){var e=t.apply(this,x([],d(arguments),!1))||this;return e.movement=O(0,0),e.previousMovement=O(0,0),e.velocity=O(0,0),e.direction=O(0,0),e}return f(e,t),e.prototype._initEvents=function(){this.targetElement?this._subscribe=T([this.targetElement],[["mousemove",this.onMouseMove.bind(this)]]):this.targetElements.length>0?this._subscribe=T(this.targetElements,[["mousemove",this.onMouseMove.bind(this)]]):this._subscribe=T([window],[["mousemove",this.onMouseMove.bind(this)]])},e.prototype._handleCallback=function(){var t;this.callback&&this.callback({args:[this.currentIndex],event:this.event,isMoving:this.isActive,target:null===(t=this.event)||void 0===t?void 0:t.target,mouseX:this.movement.x,mouseY:this.movement.y,velocityX:this.velocity.x,velocityY:this.velocity.y,directionX:this.direction.x,directionY:this.direction.y})},e.prototype.onMouseMove=function(t){var e=this,n=this.targetElements.find((function(e){return e===t.target}));n&&(this.currentIndex=this.targetElements.indexOf(n)),this.event=t;var i=Date.now(),r=Math.min(i-this.lastTimeStamp,64);this.lastTimeStamp=i;var o=r/1e3,s=t.clientX,u=t.clientY;this.movement={x:s,y:u},-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){e.isActive=!1,e.direction={x:0,y:0},e.velocity={x:0,y:0},e._handleCallback()}),250);var c=this.movement.x-this.previousMovement.x,a=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(c),y:Math.sign(a)},this.velocity={x:M(c/o/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT),y:M(a/o/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},e}(k),S=function(t){function e(){var e=t.apply(this,x([],d(arguments),!1))||this;return e.movement=O(0,0),e.previousMovement=O(0,0),e.direction=O(0,0),e.velocity=O(0,0),e}return f(e,t),e.prototype._initEvents=function(){this.targetElement?this._subscribe=T([this.targetElement],[["scroll",this.scrollElementListener.bind(this)]]):this._subscribe=T([window],[["scroll",this.scrollListener.bind(this)]])},e.prototype._handleCallback=function(){this.callback&&this.callback({isScrolling:this.isActive,scrollX:this.movement.x,scrollY:this.movement.y,velocityX:this.velocity.x,velocityY:this.velocity.y,directionX:this.direction.x,directionY:this.direction.y})},e.prototype.onScroll=function(t){var e=this,n=t.x,i=t.y,r=Date.now(),o=Math.min(r-this.lastTimeStamp,64);this.lastTimeStamp=r;var s=o/1e3;this.movement={x:n,y:i},-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){e.isActive=!1,e.direction={x:0,y:0},e.velocity={x:0,y:0},e._handleCallback()}),250);var u=this.movement.x-this.previousMovement.x,c=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(u),y:Math.sign(c)},this.velocity={x:M(u/s/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT),y:M(c/s/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},e.prototype.scrollListener=function(){var t=window.pageYOffset,e=window.pageXOffset;this.onScroll({x:e,y:t})},e.prototype.scrollElementListener=function(){var t,e,n=(null===(t=this.targetElement)||void 0===t?void 0:t.scrollLeft)||0,i=(null===(e=this.targetElement)||void 0===e?void 0:e.scrollTop)||0;this.onScroll({x:n,y:i})},e}(k),A=function(t){function e(){var e=t.apply(this,x([],d(arguments),!1))||this;return e.movement=O(0,0),e.previousMovement=O(0,0),e.direction=O(0,0),e.velocity=O(0,0),e.delta=O(0,0),e.offset=O(0,0),e.translation=O(0,0),e}return f(e,t),e.prototype._initEvents=function(){this.targetElement&&(this._subscribe=T([this.targetElement],[["wheel",this.onWheel.bind(this)]]))},e.prototype._handleCallback=function(){this.callback&&this.callback({target:this.targetElement,isWheeling:this.isActive,deltaX:this.delta.x,deltaY:this.delta.y,directionX:this.direction.x,directionY:this.direction.y,movementX:this.movement.x,movementY:this.movement.y,offsetX:this.offset.x,offsetY:this.offset.y,velocityX:this.velocity.x,velocityY:this.velocity.y})},e.prototype.onWheel=function(t){var e=this,n=t.deltaX,i=t.deltaY,r=t.deltaMode,o=Date.now(),s=Math.min(o-this.lastTimeStamp,64);this.lastTimeStamp=o;var u=s/1e3;this.isActive=!0,-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){e.isActive=!1,e.translation={x:e.offset.x,y:e.offset.y},e._handleCallback(),e.velocity={x:0,y:0},e.movement={x:0,y:0}}),200),1===r?(n*=40,i*=40):2===r&&(n*=800,i*=800),this.delta={x:n,y:i},this.movement={x:this.movement.x+n,y:this.movement.y+i},this.offset={x:this.translation.x+this.movement.x,y:this.translation.y+this.movement.y};var c=this.movement.x-this.previousMovement.x,a=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(c),y:Math.sign(a)},this.velocity={x:M(c/u/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT),y:M(a/u/1e3,-1*k._VELOCITY_LIMIT,k._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},e}(k),C=function(t){var e=r.useRef(),n=r.useRef([]),i=r.useRef(new Map).current;return r.useEffect((function(){var e,n;try{for(var r=y(i.entries()),o=r.next();!o.done;o=r.next()){var s=d(o.value,2)[1],u=s.keyIndex,c=s.gesture,a=d(t[u],3)[2];c.applyCallback(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}}),[t]),r.useEffect((function(){return t.forEach((function(t,r){var o=d(t,4),s=o[0],u=o[1],c=o[2],a=o[3];queueMicrotask((function(){return i.set(s,{keyIndex:r,gesture:u,unsubscribe:u.applyGesture({targetElement:e.current,targetElements:n.current,callback:c,config:a})})}))})),function(){var t,e;try{for(var n=y(i.entries()),r=n.next();!r.done;r=n.next()){var o=d(r.value,2)[1].unsubscribe;o&&o()}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}}})),function(t){return null==t?{ref:e}:(n.current[t]=n.current[t]||r.createRef(),{ref:n.current[t]})}};Object.defineProperty(exports,"Easing",{enumerable:!0,get:function(){return t.Easing}}),Object.defineProperty(exports,"animate",{enumerable:!0,get:function(){return t.fluid}}),Object.defineProperty(exports,"makeAnimated",{enumerable:!0,get:function(){return t.makeFluid}}),exports.AnimatedBlock=u,exports.AnimatedImage=a,exports.AnimatedInline=c,exports.AnimationConfigUtils=g,exports.MountedBlock=function(t){var n=t.state,i=t.children,r=t.from,o=void 0===r?0:r,s=t.enter,u=void 0===s?1:s,c=t.exit,a=l(n,{from:o,enter:u,exit:void 0===c?0:c,config:t.config});return e.jsx(e.Fragment,{children:a((function(t,e){return e&&i({value:t.value})}))})},exports.ScrollableBlock=function(t){var n=t.children,i=t.direction,o=void 0===i?"single":i,s=t.animationConfig,u=t.threshold,c=void 0===u?.2:u,a=r.useRef(null),l=E(0,s);return r.useEffect((function(){var t=a.current,e=new IntersectionObserver((function(t){d(t,1)[0].isIntersecting?l.value=1:"both"===o&&(l.value=0)}),{root:null,threshold:c});return t&&e.observe(t),function(){t&&e.unobserve(t)}}),[]),e.jsx("div",{ref:a,children:n&&n({value:l.value})})},exports.TransitionBlock=function(t){var n=t.state,i=t.children,r=t.config,o=E(w(n),r);return e.jsx(e.Fragment,{children:i({value:o.value})})},exports.bInterpolate=function(e,n,i,r){var o=s(e);return t.interpolate(o,[0,1],[n,i],r)},exports.bin=w,exports.clamp=M,exports.delay=function(t){return new Promise((function(e){setTimeout((function(){return e(null)}),t)}))},exports.interpolate=function(e,n,i,r){var o=s(e);return t.interpolate(o,n,i,r)},exports.mix=function(t,e,n){return e*(1-t)+n*t},exports.move=function(t,e,n){var i=t[e],r=t.length,o=e-n;if(o>0)return x(x(x(x([],d(t.slice(0,n)),!1),[i],!1),d(t.slice(n,e)),!1),d(t.slice(e+1,r)),!1);if(o<0){var s=n+1;return x(x(x(x([],d(t.slice(0,e)),!1),d(t.slice(e+1,s)),!1),[i],!1),d(t.slice(s,r)),!1)}return t},exports.rubberClamp=function(t,e,n,i){return void 0===i&&(i=.15),0===i?M(t,e,n):t<e?-_(e-t,n-e,i)+e:t>n?+_(t-n,n-e,i)+n:t},exports.snapTo=function(t,e,n){var i=t+.2*e,r=function(t){return Math.abs(t-i)},o=n.map(r),s=Math.min.apply(Math,x([],d(o),!1));return n.reduce((function(t,e){return r(e)===s?e:t}))},exports.useAnimatedValue=E,exports.useDrag=function(t,e){var n=r.useRef(new L).current;return C([["drag",n,t,e]])},exports.useGesture=function(t){var e=t.onDrag,n=t.onWheel,i=t.onScroll,o=t.onMouseMove,s=r.useRef(new L).current,u=r.useRef(new A).current,c=r.useRef(new S).current,a=r.useRef(new Y).current;return C([["drag",s,e],["wheel",u,n],["scroll",c,i],["move",a,o]])},exports.useMeasure=function(t,e){var i=n.useRef(null),r=n.useRef([]),o=n.useRef(t);return n.useEffect((function(){return o.current=t,function(){o.current=function(){return!1}}}),e),n.useEffect((function(){var t=i.current||document.documentElement,e=r.current,n=new ResizeObserver((function(e){var n=d(e,1)[0].target.getBoundingClientRect(),i=n.left,r=n.top,s=n.width,u=n.height,c=window.pageXOffset,a=window.pageYOffset;if(o){if(t===document.documentElement)return;o.current({left:i+c,top:r+a,width:s,height:u,vLeft:i,vTop:r})}})),s=new ResizeObserver((function(t){var e=[],n=[],i=[],r=[],s=[],u=[];t.forEach((function(t){var o=t.target.getBoundingClientRect(),c=o.left,a=o.top,l=o.width,h=o.height,f=c+window.pageXOffset,v=a+window.pageYOffset;e.push(f),n.push(v),i.push(l),r.push(h),s.push(c),u.push(a)})),o&&o.current({left:e,top:n,width:i,height:r,vLeft:s,vTop:u})}));return t&&(t===document.documentElement&&e.length>0?e.forEach((function(t){s.observe(t.current)})):n.observe(t)),function(){t&&(t===document.documentElement&&e.length>0?e.forEach((function(t){s.unobserve(t.current)})):n.unobserve(t))}}),[]),function(t){return null==t?{ref:i}:(r.current[t]=r.current[t]||n.createRef(),{ref:r.current[t]})}},exports.useMountedValue=l,exports.useMouseMove=function(t){var e=r.useRef(new Y).current;return C([["move",e,t]])},exports.useOutsideClick=function(t,e,i){var r=n.useRef();r.current||(r.current=e),n.useEffect((function(){return r.current=e,function(){r.current=function(){return!1}}}),i),n.useEffect((function(){var e=T([document],[["click",function(e){var n;(null===(n=null==t?void 0:t.current)||void 0===n?void 0:n.contains(e.target))||r.current&&r.current(e)}]]);return function(){return e&&e()}}),[])},exports.useScroll=function(t){var e=r.useRef(new S).current;return C([["scroll",e,t]])},exports.useWheel=function(t){var e=r.useRef(new A).current;return C([["wheel",e,t]])},exports.useWindowDimension=function(t,e){var i=n.useRef({width:0,height:0,innerWidth:0,innerHeight:0}),r=n.useRef(t);n.useEffect((function(){return r.current=t,function(){r.current=function(){return!1}}}),e),n.useEffect((function(){var t=new ResizeObserver((function(t){var e=d(t,1)[0].target,n=e.clientWidth,o=e.clientHeight,s=window.innerWidth,u=window.innerHeight;i.current={width:n,height:o,innerWidth:s,innerHeight:u},r&&r.current(v({},i.current))}));return t.observe(document.documentElement),function(){return t.unobserve(document.documentElement)}}),[])},exports.withConfig=I,exports.withDecay=function(t){return{config:t}},exports.withDelay=function(t,e){return v(v({},e),{config:v(v({},e.config),{delay:t})})},exports.withEase=function(t,e){return I(t,v(v({},g.EASE),e))},exports.withSequence=function(t){return function(e){return m(void 0,void 0,void 0,(function(){var n,i,r,o,s,u;return p(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,7]),n=y(t),i=n.next(),c.label=1;case 1:return i.done?[3,4]:(r=i.value,[4,e("number"==typeof r?{toValue:r}:r)]);case 2:c.sent(),c.label=3;case 3:return i=n.next(),[3,1];case 4:return[3,7];case 5:return o=c.sent(),s={error:o},[3,7];case 6:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))}},exports.withSpring=function(t,e){return I(t,v(v({},g.ELASTIC),e))},exports.withTiming=function(t,e){return I(t,v({duration:250},e))};
|
|
1
|
+
var t=require("@raidipesh78/re-motion"),e=require("react/jsx-runtime"),n=require("react");function i(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var r=i(n),o=function(t,e,n,i){return t.interpolate(e,n,i)},s=function(t){return null!=t};function u(e){if(!(s(e)&&e instanceof t.FluidValue))throw console.log(e),new Error("Invalid ".concat(e," type for interpolate function. Expected FluidValue."));return e}var a=function(t,e){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},a(t,e)};function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var l=function(){return l=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},l.apply(this,arguments)};function f(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{a(i.next(t))}catch(t){o(t)}}function u(t){try{a(i.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((i=i.apply(t,e||[])).next())}))}function h(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&u[0]?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,i=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=e.call(t,s)}catch(t){u=[6,t],i=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function v(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function d(t,e,n){if(n||2===arguments.length)for(var i,r=0,o=e.length;r<o;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var p=function(){function e(e,n){this.fluid=new t.FluidValue(e),this.defaultConfig=n}return e.prototype.runAnimation=function(e,n){var i=l(l({},this.defaultConfig),e.config);this.fluid.removeAllListeners(),(null==i?void 0:i.onStart)&&i.onStart(this.fluid.get()),(null==i?void 0:i.onChange)&&this.fluid.addListener((function(t){var e;return null===(e=null==i?void 0:i.onChange)||void 0===e?void 0:e.call(i,t)}));var r=function(t){var e,r=t.finished,o=t.value;r&&(null===(e=null==i?void 0:i.onRest)||void 0===e||e.call(i,o),null==n||n(o))};if(s(null==i?void 0:i.duration)||(null==i?void 0:i.immediate)){if(!s(e.toValue))throw new Error("No `toValue` is defined");var o={toValue:e.toValue,delay:null==i?void 0:i.delay,duration:(null==i?void 0:i.immediate)?0:null==i?void 0:i.duration,easing:null==i?void 0:i.easing};t.timing(this.fluid,o).start(r)}else if(null==i?void 0:i.decay){var u={velocity:null==i?void 0:i.velocity,deceleration:null==i?void 0:i.deceleration,delay:null==i?void 0:i.delay};t.decay(this.fluid,u).start(r)}else{if(!s(e.toValue))throw new Error("No `toValue` is defined");var a={toValue:e.toValue,delay:null==i?void 0:i.delay,mass:null==i?void 0:i.mass,tension:null==i?void 0:i.tension,friction:null==i?void 0:i.friction,restDistance:null==i?void 0:i.restDistance};t.spring(this.fluid,a).start(r)}},e.prototype.setFluid=function(t,e){var n=this;t&&("function"==typeof t?t((function(t){return new Promise((function(i){n.runAnimation(t,(function(n){i(t),e&&e(n)}))}))})):this.runAnimation(t,e))},e.prototype.getFluid=function(){return this.fluid},e}(),y=function(){function t(t,e){this.fluidControllers=t.map((function(t){return new p(t,e)}))}return t.prototype.setFluid=function(t,e){this.fluidControllers.map((function(n,i){n.setFluid(t[i],e)}))},t.prototype.getFluid=function(){return this.fluidControllers.map((function(t){return t.getFluid()}))},t}(),g=function(t,e){var i=n.useRef(Array.isArray(t)?new y(t,e):new p(t,e)).current,r=n.useCallback((function(t,e){i.setFluid(t,e)}),[]);return[n.useMemo((function(){return i.getFluid()}),[]),r]};function b(t,e){var i=function(t,e){var i=m(n.useState(!1),2),r=i[0],o=i[1],s=n.useRef(e).current,u=s.from,a=s.enter,c=s.exit,l=s.config,f=m(g(u,l),2),h=f[0],v=f[1];return n.useLayoutEffect((function(){t?(o(!0),queueMicrotask((function(){return v("number"==typeof a?{toValue:a,config:l}:a)}))):v("number"==typeof c?{toValue:c,config:l}:c,(function(){o(!1),h.getSubscriptions().forEach((function(t){return h.removeSubscription(t)}))}))}),[t,e]),function(t){return t(h,r)}}(t,e);return function(t){return i((function(e,n){return t({value:e},n)}))}}var x=function(e){switch(e){case"elastic":return{mass:1,friction:18,tension:250};case"stiff":return{mass:1,friction:18,tension:350};case"wooble":return{mass:1,friction:8,tension:250};case"bounce":return{duration:500,easing:t.Easing.bounce};case"power1":return{duration:500,easing:t.Easing.bezier(.17,.42,.51,.97)};case"power2":return{duration:500,easing:t.Easing.bezier(.07,.11,.13,1)};case"power3":return{duration:500,easing:t.Easing.bezier(.09,.7,.16,1.04)};case"power4":return{duration:500,easing:t.Easing.bezier(.05,.54,0,1.03)};case"linear":return{duration:500,easing:t.Easing.linear};case"easein":return{duration:500,easing:t.Easing.in(t.Easing.ease)};case"easeout":return{duration:500,easing:t.Easing.out(t.Easing.ease)};case"easeinout":return{duration:500,easing:t.Easing.inOut(t.Easing.ease)};default:return{mass:1,friction:26,tension:170}}},E={ELASTIC:x("elastic"),BOUNCE:x("bounce"),EASE:x("ease"),STIFF:x("stiff"),WOOBLE:x("wooble"),EASE_IN:x("easein"),EASE_OUT:x("easeout"),EASE_IN_OUT:x("easeinout"),POWER1:x("power1"),POWER2:x("power2"),POWER3:x("power3"),POWER4:x("power4"),LINEAR:x("linear")},w=function(t){return"number"==typeof t?{toValue:t}:t};function M(t,e){var i=n.useRef(!0),r=m(g(t,l(l({},E.EASE),e)),2),o=r[0],s=r[1],u=Array.isArray(o)?o.map((function(t){return t.get()})):o.get(),a={value:o,currentValue:u},c=n.useCallback((function(t){var e=w(t);Array.isArray(t)?s(t.map((function(t){return w(t)}))):queueMicrotask((function(){return s(e)}))}),[]);return n.useLayoutEffect((function(){i.current||c(t),i.current=!1}),[t,e]),new Proxy(a,{set:function(t,e,n){if("value"===e)return c(n),!0;throw new Error("You cannot set any other property to animation node.")},get:function(t,e){if("value"===e)return o;if("currentValue"===e)return Array.isArray(o)?o.map((function(t){return t.get()})):o.get();throw new Error("You cannot access any other property from animation node.")}})}function _(t){return t?1:0}function I(t,e,n){return Math.min(Math.max(t,e),n)}function T(t,e,n){return 0===e||Math.abs(e)===1/0?function(t,e){return Math.pow(t,5*e)}(t,n):t*e*n/(e+n*t)}var O=function(t,e){return{toValue:t,config:e}};function A(t,e){var n=new Map;return e.forEach((function(e){var i=m(e,3),r=i[0],o=i[1],s=i[2],u=void 0!==s&&s;n.set(r,function(t,e,n,i){return void 0===i&&(i=!1),t.forEach((function(t){t.addEventListener(e,n,i)})),function(){t.forEach((function(t){t.removeEventListener(e,n,i)}))}}(t,r,o,u))})),function(t){var e,i;try{for(var r=v(n.entries()),o=r.next();!o.done;o=r.next()){var s=m(o.value,2),u=s[0],a=s[1];if(!t)return void a();-1!==t.indexOf(u)&&a()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}}var C=function(t,e){return{x:t,y:e}},L=function(){function t(){this.lastTimeStamp=Date.now(),this.isActive=!1,this.targetElements=[]}return t.prototype._initEvents=function(){},t.prototype._cancelEvents=function(){this._subscribe&&this._subscribe()},t.prototype.applyCallback=function(t){this.callback=t},t.prototype.applyGesture=function(t){var e=this,n=t.targetElement,i=t.targetElements,r=t.callback,o=t.config;return this.targetElement=n,this.targetElements=i.map((function(t){return t.current})),this.callback=r,this.config=o,this._initEvents(),function(){return e._subscribe&&e._subscribe()}},t._VELOCITY_LIMIT=20,t}(),S=function(t){function e(){var e=t.apply(this,d([],m(arguments),!1))||this;return e.movementStart=C(0,0),e.initialMovement=C(0,0),e.movement=C(0,0),e.previousMovement=C(0,0),e.translation=C(0,0),e.offset=C(0,0),e.velocity=C(0,0),e}return c(e,t),e.prototype._initEvents=function(){(this.targetElement||this.targetElements.length>0)&&(this._subscribe=A([window],[["mousedown",this.pointerDown.bind(this)],["mousemove",this.pointerMove.bind(this)],["mouseup",this.pointerUp.bind(this)],["touchstart",this.pointerDown.bind(this),{passive:!1}],["touchmove",this.pointerMove.bind(this),{passive:!1}],["touchend",this.pointerUp.bind(this)]]))},e.prototype._cancelEvents=function(){this._subscribe&&this._subscribe(["mousedown","mousemove","touchstart","touchmove"])},e.prototype._handleCallback=function(){var t=this;this.callback&&this.callback({args:[this.currentIndex],down:this.isActive,movementX:this.movement.x,movementY:this.movement.y,offsetX:this.translation.x,offsetY:this.translation.y,velocityX:this.velocity.x,velocityY:this.velocity.y,distanceX:Math.abs(this.movement.x),distanceY:Math.abs(this.movement.y),directionX:Math.sign(this.movement.x),directionY:Math.sign(this.movement.y),cancel:function(){t._cancelEvents()}})},e.prototype.pointerDown=function(t){var e;"touchstart"===t.type?this.movementStart={x:t.touches[0].clientX,y:t.touches[0].clientY}:this.movementStart={x:t.clientX,y:t.clientY},this.movement={x:0,y:0},this.offset={x:this.translation.x,y:this.translation.y},this.previousMovement={x:0,y:0},this.velocity={x:0,y:0};var n=this.targetElements.find((function(e){return e===t.target}));if(t.target===this.targetElement||n){this.isActive=!0,t.preventDefault(),n&&(this.currentIndex=this.targetElements.indexOf(n));var i=(null===(e=this.config)||void 0===e?void 0:e.initial)&&this.config.initial(),r=null==i?void 0:i.movementX,o=null==i?void 0:i.movementY;this.initialMovement={x:null!=r?r:0,y:null!=o?o:0},this.movement={x:this.initialMovement.x,y:this.initialMovement.y},this.previousMovement={x:this.initialMovement.x,y:this.initialMovement.y},this._handleCallback()}},e.prototype.pointerMove=function(t){if(this.isActive){t.preventDefault();var e=Date.now(),n=I(e-this.lastTimeStamp,.1,64);this.lastTimeStamp=e;var i=n/1e3;"touchmove"===t.type?this.movement={x:this.initialMovement.x+(t.touches[0].clientX-this.movementStart.x),y:this.initialMovement.y+(t.touches[0].clientY-this.movementStart.y)}:this.movement={x:this.initialMovement.x+(t.clientX-this.movementStart.x),y:this.initialMovement.y+(t.clientY-this.movementStart.y)},this.translation={x:this.offset.x+this.movement.x,y:this.offset.y+this.movement.y},this.velocity={x:I((this.movement.x-this.previousMovement.x)/i/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT),y:I((this.movement.y-this.previousMovement.y)/i/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()}},e.prototype.pointerUp=function(){this.isActive&&(this.isActive=!1,this._handleCallback(),this._cancelEvents(),this._initEvents())},e}(L),k=function(t){function e(){var e=t.apply(this,d([],m(arguments),!1))||this;return e.movement=C(0,0),e.previousMovement=C(0,0),e.velocity=C(0,0),e.direction=C(0,0),e}return c(e,t),e.prototype._initEvents=function(){this.targetElement?this._subscribe=A([this.targetElement],[["mousemove",this.onMouseMove.bind(this)]]):this.targetElements.length>0?this._subscribe=A(this.targetElements,[["mousemove",this.onMouseMove.bind(this)]]):this._subscribe=A([window],[["mousemove",this.onMouseMove.bind(this)]])},e.prototype._handleCallback=function(){var t;this.callback&&this.callback({args:[this.currentIndex],event:this.event,isMoving:this.isActive,target:null===(t=this.event)||void 0===t?void 0:t.target,mouseX:this.movement.x,mouseY:this.movement.y,velocityX:this.velocity.x,velocityY:this.velocity.y,directionX:this.direction.x,directionY:this.direction.y})},e.prototype.onMouseMove=function(t){var e=this,n=this.targetElements.find((function(e){return e===t.target}));n&&(this.currentIndex=this.targetElements.indexOf(n)),this.event=t;var i=Date.now(),r=Math.min(i-this.lastTimeStamp,64);this.lastTimeStamp=i;var o=r/1e3,s=t.clientX,u=t.clientY;this.movement={x:s,y:u},-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){e.isActive=!1,e.direction={x:0,y:0},e.velocity={x:0,y:0},e._handleCallback()}),250);var a=this.movement.x-this.previousMovement.x,c=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(a),y:Math.sign(c)},this.velocity={x:I(a/o/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT),y:I(c/o/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},e}(L),Y=function(t){function e(){var e=t.apply(this,d([],m(arguments),!1))||this;return e.movement=C(0,0),e.previousMovement=C(0,0),e.direction=C(0,0),e.velocity=C(0,0),e}return c(e,t),e.prototype._initEvents=function(){this.targetElement?this._subscribe=A([this.targetElement],[["scroll",this.scrollElementListener.bind(this)]]):this._subscribe=A([window],[["scroll",this.scrollListener.bind(this)]])},e.prototype._handleCallback=function(){this.callback&&this.callback({isScrolling:this.isActive,scrollX:this.movement.x,scrollY:this.movement.y,velocityX:this.velocity.x,velocityY:this.velocity.y,directionX:this.direction.x,directionY:this.direction.y})},e.prototype.onScroll=function(t){var e=this,n=t.x,i=t.y,r=Date.now(),o=Math.min(r-this.lastTimeStamp,64);this.lastTimeStamp=r;var s=o/1e3;this.movement={x:n,y:i},-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){e.isActive=!1,e.direction={x:0,y:0},e.velocity={x:0,y:0},e._handleCallback()}),250);var u=this.movement.x-this.previousMovement.x,a=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(u),y:Math.sign(a)},this.velocity={x:I(u/s/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT),y:I(a/s/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},e.prototype.scrollListener=function(){var t=window.pageYOffset,e=window.pageXOffset;this.onScroll({x:e,y:t})},e.prototype.scrollElementListener=function(){var t,e,n=(null===(t=this.targetElement)||void 0===t?void 0:t.scrollLeft)||0,i=(null===(e=this.targetElement)||void 0===e?void 0:e.scrollTop)||0;this.onScroll({x:n,y:i})},e}(L),V=function(t){function e(){var e=t.apply(this,d([],m(arguments),!1))||this;return e.movement=C(0,0),e.previousMovement=C(0,0),e.direction=C(0,0),e.velocity=C(0,0),e.delta=C(0,0),e.offset=C(0,0),e.translation=C(0,0),e}return c(e,t),e.prototype._initEvents=function(){this.targetElement&&(this._subscribe=A([this.targetElement],[["wheel",this.onWheel.bind(this)]]))},e.prototype._handleCallback=function(){this.callback&&this.callback({target:this.targetElement,isWheeling:this.isActive,deltaX:this.delta.x,deltaY:this.delta.y,directionX:this.direction.x,directionY:this.direction.y,movementX:this.movement.x,movementY:this.movement.y,offsetX:this.offset.x,offsetY:this.offset.y,velocityX:this.velocity.x,velocityY:this.velocity.y})},e.prototype.onWheel=function(t){var e=this,n=t.deltaX,i=t.deltaY,r=t.deltaMode,o=Date.now(),s=Math.min(o-this.lastTimeStamp,64);this.lastTimeStamp=o;var u=s/1e3;this.isActive=!0,-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){e.isActive=!1,e.translation={x:e.offset.x,y:e.offset.y},e._handleCallback(),e.velocity={x:0,y:0},e.movement={x:0,y:0}}),200),1===r?(n*=40,i*=40):2===r&&(n*=800,i*=800),this.delta={x:n,y:i},this.movement={x:this.movement.x+n,y:this.movement.y+i},this.offset={x:this.translation.x+this.movement.x,y:this.translation.y+this.movement.y};var a=this.movement.x-this.previousMovement.x,c=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(a),y:Math.sign(c)},this.velocity={x:I(a/u/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT),y:I(c/u/1e3,-1*L._VELOCITY_LIMIT,L._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},e}(L),R=function(t){var e=r.useRef(),n=r.useRef([]),i=r.useRef(new Map).current;return r.useEffect((function(){var e,n;try{for(var r=v(i.entries()),o=r.next();!o.done;o=r.next()){var s=m(o.value,2)[1],u=s.keyIndex,a=s.gesture,c=m(t[u],3)[2];a.applyCallback(c)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}}),[t]),r.useEffect((function(){return t.forEach((function(t,r){var o=m(t,4),s=o[0],u=o[1],a=o[2],c=o[3];queueMicrotask((function(){return i.set(s,{keyIndex:r,gesture:u,unsubscribe:u.applyGesture({targetElement:e.current,targetElements:n.current,callback:a,config:c})})}))})),function(){var t,e;try{for(var n=v(i.entries()),r=n.next();!r.done;r=n.next()){var o=m(r.value,2)[1].unsubscribe;o&&o()}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}}})),function(t){return null==t?{ref:e}:(n.current[t]=n.current[t]||r.createRef(),{ref:n.current[t]})}};Object.defineProperty(exports,"Easing",{enumerable:!0,get:function(){return t.Easing}}),Object.defineProperty(exports,"animate",{enumerable:!0,get:function(){return t.fluid}}),Object.defineProperty(exports,"makeAnimated",{enumerable:!0,get:function(){return t.makeFluid}}),exports.AnimationConfigUtils=E,exports.MountedBlock=function(t){var n=t.state,i=t.children,r=t.from,o=void 0===r?0:r,s=t.enter,u=void 0===s?1:s,a=t.exit,c=b(n,{from:o,enter:u,exit:void 0===a?0:a,config:t.config});return e.jsx(e.Fragment,{children:c((function(t,e){return e&&i({value:t.value})}))})},exports.ScrollableBlock=function(t){var n=t.children,i=t.direction,o=void 0===i?"single":i,s=t.animationConfig,u=t.threshold,a=void 0===u?.2:u,c=r.useRef(null),l=M(0,s);return r.useEffect((function(){var t=c.current,e=new IntersectionObserver((function(t){m(t,1)[0].isIntersecting?l.value=1:"both"===o&&(l.value=0)}),{root:null,threshold:a});return t&&e.observe(t),function(){t&&e.unobserve(t)}}),[]),e.jsx("div",{ref:c,children:n&&n({value:l.value})})},exports.TransitionBlock=function(t){var n=t.state,i=t.children,r=t.config,o=M(_(n),r);return e.jsx(e.Fragment,{children:i({value:o.value})})},exports.bInterpolate=function(t,e,n,i){var r=u(t);return o(r,[0,1],[e,n],i)},exports.bin=_,exports.clamp=I,exports.delay=function(t){return new Promise((function(e){setTimeout((function(){return e(null)}),t)}))},exports.interpolate=function(t,e,n,i){var r=u(t);return o(r,e,n,i)},exports.mix=function(t,e,n){return e*(1-t)+n*t},exports.move=function(t,e,n){var i=t[e],r=t.length,o=e-n;if(o>0)return d(d(d(d([],m(t.slice(0,n)),!1),[i],!1),m(t.slice(n,e)),!1),m(t.slice(e+1,r)),!1);if(o<0){var s=n+1;return d(d(d(d([],m(t.slice(0,e)),!1),m(t.slice(e+1,s)),!1),[i],!1),m(t.slice(s,r)),!1)}return t},exports.rubberClamp=function(t,e,n,i){return void 0===i&&(i=.15),0===i?I(t,e,n):t<e?-T(e-t,n-e,i)+e:t>n?+T(t-n,n-e,i)+n:t},exports.snapTo=function(t,e,n){var i=t+.2*e,r=function(t){return Math.abs(t-i)},o=n.map(r),s=Math.min.apply(Math,d([],m(o),!1));return n.reduce((function(t,e){return r(e)===s?e:t}))},exports.useAnimatedValue=M,exports.useDrag=function(t,e){var n=r.useRef(new S).current;return R([["drag",n,t,e]])},exports.useGesture=function(t){var e=t.onDrag,n=t.onWheel,i=t.onScroll,o=t.onMouseMove,s=r.useRef(new S).current,u=r.useRef(new V).current,a=r.useRef(new Y).current,c=r.useRef(new k).current;return R([["drag",s,e],["wheel",u,n],["scroll",a,i],["move",c,o]])},exports.useMeasure=function(t,e){var i=n.useRef(null),r=n.useRef([]),o=n.useRef(t);return n.useEffect((function(){return o.current=t,function(){o.current=function(){return!1}}}),e),n.useEffect((function(){var t=i.current||document.documentElement,e=r.current,n=new ResizeObserver((function(e){var n=m(e,1)[0].target.getBoundingClientRect(),i=n.left,r=n.top,s=n.width,u=n.height,a=window.pageXOffset,c=window.pageYOffset;if(o){if(t===document.documentElement)return;o.current({left:i+a,top:r+c,width:s,height:u,vLeft:i,vTop:r})}})),s=new ResizeObserver((function(t){var e=[],n=[],i=[],r=[],s=[],u=[];t.forEach((function(t){var o=t.target.getBoundingClientRect(),a=o.left,c=o.top,l=o.width,f=o.height,h=a+window.pageXOffset,v=c+window.pageYOffset;e.push(h),n.push(v),i.push(l),r.push(f),s.push(a),u.push(c)})),o&&o.current({left:e,top:n,width:i,height:r,vLeft:s,vTop:u})}));return t&&(t===document.documentElement&&e.length>0?e.forEach((function(t){s.observe(t.current)})):n.observe(t)),function(){t&&(t===document.documentElement&&e.length>0?e.forEach((function(t){s.unobserve(t.current)})):n.unobserve(t))}}),[]),function(t){return null==t?{ref:i}:(r.current[t]=r.current[t]||n.createRef(),{ref:r.current[t]})}},exports.useMountedValue=b,exports.useMouseMove=function(t){var e=r.useRef(new k).current;return R([["move",e,t]])},exports.useOutsideClick=function(t,e,i){var r=n.useRef();r.current||(r.current=e),n.useEffect((function(){return r.current=e,function(){r.current=function(){return!1}}}),i),n.useEffect((function(){var e=A([document],[["click",function(e){var n;(null===(n=null==t?void 0:t.current)||void 0===n?void 0:n.contains(e.target))||r.current&&r.current(e)}]]);return function(){return e&&e()}}),[])},exports.useScroll=function(t){var e=r.useRef(new Y).current;return R([["scroll",e,t]])},exports.useWheel=function(t){var e=r.useRef(new V).current;return R([["wheel",e,t]])},exports.useWindowDimension=function(t,e){var i=n.useRef({width:0,height:0,innerWidth:0,innerHeight:0}),r=n.useRef(t);n.useEffect((function(){return r.current=t,function(){r.current=function(){return!1}}}),e),n.useEffect((function(){var t=new ResizeObserver((function(t){var e=m(t,1)[0].target,n=e.clientWidth,o=e.clientHeight,s=window.innerWidth,u=window.innerHeight;i.current={width:n,height:o,innerWidth:s,innerHeight:u},r&&r.current(l({},i.current))}));return t.observe(document.documentElement),function(){return t.unobserve(document.documentElement)}}),[])},exports.withConfig=O,exports.withDecay=function(t){return{config:l({decay:!0},t)}},exports.withDelay=function(t,e){return l(l({},e),{config:l(l({},e.config),{delay:t})})},exports.withEase=function(t,e){return O(t,l(l({},E.EASE),e))},exports.withSequence=function(t){return function(e){return f(void 0,void 0,void 0,(function(){var n,i,r,o,s,u;return h(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),n=v(t),i=n.next(),a.label=1;case 1:return i.done?[3,4]:(r=i.value,[4,e("number"==typeof r?{toValue:r}:r)]);case 2:a.sent(),a.label=3;case 3:return i=n.next(),[3,1];case 4:return[3,7];case 5:return o=a.sent(),s={error:o},[3,7];case 6:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))}},exports.withSpring=function(t,e){return O(t,l(l({},E.ELASTIC),e))},exports.withTiming=function(t,e){return O(t,l({duration:250},e))};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|