react-ui-animate 2.0.0-rc.1 → 2.0.0-rc.4
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/dist/animation/animationType.d.ts +8 -0
- package/dist/animation/getInitialConfig.d.ts +2 -2
- package/dist/animation/index.d.ts +1 -0
- package/dist/animation/modules/AnimatedBlock.d.ts +8 -0
- package/dist/animation/modules/AnimatedImage.d.ts +8 -0
- package/dist/animation/modules/AnimatedInline.d.ts +8 -0
- package/dist/animation/modules/MountedBlock.d.ts +18 -0
- package/dist/animation/modules/ScrollableBlock.d.ts +21 -0
- package/dist/animation/modules/TransitionBlock.d.ts +17 -0
- package/dist/animation/modules/index.d.ts +6 -0
- package/dist/animation/useAnimatedValue.d.ts +8 -4
- package/dist/animation/useMountedValue.d.ts +5 -4
- package/dist/gestures/controllers/MouseMoveGesture.d.ts +2 -2
- package/dist/gestures/controllers/ScrollGesture.d.ts +2 -2
- package/dist/gestures/controllers/WheelGesture.d.ts +2 -2
- package/dist/gestures/controllers/index.d.ts +4 -4
- package/dist/gestures/eventAttacher.d.ts +1 -1
- package/dist/gestures/hooks/index.d.ts +5 -5
- package/dist/gestures/hooks/useDrag.d.ts +1 -1
- package/dist/gestures/hooks/useGesture.d.ts +1 -1
- package/dist/gestures/hooks/useMouseMove.d.ts +1 -1
- package/dist/gestures/hooks/useRecognizer.d.ts +1 -1
- package/dist/gestures/hooks/useScroll.d.ts +1 -1
- package/dist/gestures/hooks/useWheel.d.ts +1 -1
- package/dist/gestures/index.d.ts +2 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +216 -150
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
- package/src/animation/animationType.ts +8 -0
- package/src/animation/getInitialConfig.ts +35 -4
- package/src/animation/index.ts +1 -0
- package/src/animation/modules/AnimatedBlock.ts +8 -0
- package/src/animation/modules/AnimatedImage.ts +8 -0
- package/src/animation/modules/AnimatedInline.ts +8 -0
- package/src/animation/modules/MountedBlock.tsx +25 -0
- package/src/animation/modules/ScrollableBlock.tsx +69 -0
- package/src/animation/modules/TransitionBlock.tsx +29 -0
- package/src/animation/modules/index.ts +6 -0
- package/src/animation/useAnimatedValue.ts +15 -6
- package/src/animation/useMountedValue.ts +5 -4
- package/src/gestures/controllers/MouseMoveGesture.ts +8 -8
- package/src/gestures/controllers/ScrollGesture.ts +7 -7
- package/src/gestures/controllers/WheelGesture.ts +6 -6
- package/src/gestures/controllers/index.ts +4 -4
- package/src/gestures/eventAttacher.ts +15 -15
- package/src/gestures/hooks/index.ts +5 -5
- package/src/gestures/hooks/useDrag.ts +5 -5
- package/src/gestures/hooks/useGesture.ts +8 -8
- package/src/gestures/hooks/useMouseMove.ts +5 -5
- package/src/gestures/hooks/useRecognizer.ts +2 -2
- package/src/gestures/hooks/useScroll.ts +5 -5
- package/src/gestures/hooks/useWheel.ts +5 -5
- package/src/gestures/index.ts +2 -2
- package/src/index.ts +5 -4
- package/dist/animation/modules.d.ts +0 -55
- package/src/animation/modules.tsx +0 -105
package/dist/index.js
CHANGED
|
@@ -3,6 +3,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3
3
|
var reMotion = require('@raidipesh78/re-motion');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @param { number } ms - number of milliseconds to delay code execution
|
|
8
|
+
* @returns Promise
|
|
9
|
+
*/
|
|
10
|
+
function delay(ms) {
|
|
11
|
+
return new Promise(function (resolve) {
|
|
12
|
+
setTimeout(function () { return resolve(null); }, ms);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
/**
|
|
7
17
|
* bInterpolate functions maps input range [0, 1] to given [minOutput, maxOutput]
|
|
8
18
|
* sorthand function to interpolate input range [0, 1]
|
|
@@ -16,6 +26,27 @@ function bInterpolate(value, minOutput, maxOutput, extrapolateConfig) {
|
|
|
16
26
|
return reMotion.interpolate(value, [0, 1], [minOutput, maxOutput], extrapolateConfig);
|
|
17
27
|
}
|
|
18
28
|
|
|
29
|
+
/**
|
|
30
|
+
* AnimatedBlock - A higher order component built upon `div` element
|
|
31
|
+
* which can accept `AnimatedValue`. It also exposes some extra style properties like
|
|
32
|
+
* translateX, translateY, rotateX, rotateY, scaleX, etc.
|
|
33
|
+
*/
|
|
34
|
+
var AnimatedBlock = reMotion.makeAnimatedComponent('div');
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* AnimatedInline - A higher order component built upon `span` element
|
|
38
|
+
* which can accept `AnimatedValue`. It also exposes some extra style properties like
|
|
39
|
+
* translateX, translateY, rotateX, rotateY, scaleX, etc.
|
|
40
|
+
*/
|
|
41
|
+
var AnimatedInline = reMotion.makeAnimatedComponent('span');
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* AnimatedImage - A higher order component built upon `img` element
|
|
45
|
+
* which can accept `AnimatedValue`. It also exposes some extra style properties like
|
|
46
|
+
* translateX, translateY, rotateX, rotateY, scaleX, etc.
|
|
47
|
+
*/
|
|
48
|
+
var AnimatedImage = reMotion.makeAnimatedComponent('img');
|
|
49
|
+
|
|
19
50
|
/*! *****************************************************************************
|
|
20
51
|
Copyright (c) Microsoft Corporation.
|
|
21
52
|
|
|
@@ -92,44 +123,11 @@ function __spread() {
|
|
|
92
123
|
}
|
|
93
124
|
|
|
94
125
|
/**
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
value: animation,
|
|
101
|
-
currentValue: animation.get(),
|
|
102
|
-
};
|
|
103
|
-
return new Proxy(targetObject, {
|
|
104
|
-
set: function (_, key, value) {
|
|
105
|
-
if (key === 'value') {
|
|
106
|
-
if (typeof value === 'number' || typeof value === 'string') {
|
|
107
|
-
setAnimation({ toValue: value });
|
|
108
|
-
}
|
|
109
|
-
else if (typeof value === 'object' || typeof value === 'function') {
|
|
110
|
-
setAnimation(value);
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
throw new Error('You cannot set any other property to animation node.');
|
|
115
|
-
},
|
|
116
|
-
get: function (_, key) {
|
|
117
|
-
if (key === 'value') {
|
|
118
|
-
return animation;
|
|
119
|
-
}
|
|
120
|
-
if (key === 'currentValue') {
|
|
121
|
-
return animation.get();
|
|
122
|
-
}
|
|
123
|
-
throw new Error('You cannot access any other property from animation node.');
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* useMountedValue handles mounting and unmounting of a component
|
|
130
|
-
* @param state - boolean
|
|
131
|
-
* @param config - useTransitionConfig
|
|
132
|
-
* @returns mountedValueFunction with a callback with argument ( { value: animationNode }, mounted )
|
|
126
|
+
* `useMountedValue` handles mounting and unmounting of a component which captures current state
|
|
127
|
+
* passed as an arugment (`state`) and exposes the shadow state which handles the mount and unmount
|
|
128
|
+
* of a component.
|
|
129
|
+
* @param { boolean } state - Boolean indicating the component should mount or unmount.
|
|
130
|
+
* @param { UseMountedValueConfig } config - Animation configuration.
|
|
133
131
|
*/
|
|
134
132
|
function useMountedValue(state, config) {
|
|
135
133
|
var initial = React.useRef(true);
|
|
@@ -168,64 +166,10 @@ function useMountedValue(state, config) {
|
|
|
168
166
|
}
|
|
169
167
|
|
|
170
168
|
/**
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
function
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* AnimatedBlock : Animated Div
|
|
178
|
-
*/
|
|
179
|
-
var AnimatedBlock = reMotion.makeAnimatedComponent('div');
|
|
180
|
-
/**
|
|
181
|
-
* AnimatedInline : Animated Span
|
|
182
|
-
*/
|
|
183
|
-
var AnimatedInline = reMotion.makeAnimatedComponent('span');
|
|
184
|
-
/**
|
|
185
|
-
* AnimatedImage : Animated Image
|
|
186
|
-
*/
|
|
187
|
-
var AnimatedImage = reMotion.makeAnimatedComponent('img');
|
|
188
|
-
/**
|
|
189
|
-
* ScrollableBlock
|
|
190
|
-
* Used to animate element when enter into viewport
|
|
191
|
-
* Render props pattern with children accepts animation node
|
|
192
|
-
* animated value goes from 0 to 1 when appear on viewport & vice versa.
|
|
193
|
-
*/
|
|
194
|
-
var ScrollableBlock = function (props) {
|
|
195
|
-
var children = props.children, _a = props.direction, direction = _a === void 0 ? 'single' : _a, animationConfig = props.animationConfig, _b = props.threshold, threshold = _b === void 0 ? 0.2 : _b;
|
|
196
|
-
var scrollableBlockRef = React.useRef(null);
|
|
197
|
-
var animation = useAnimatedValue(0, animationConfig); // 0: not intersecting | 1: intersecting
|
|
198
|
-
React.useEffect(function () {
|
|
199
|
-
var _scrollableBlock = scrollableBlockRef.current;
|
|
200
|
-
var observer = new IntersectionObserver(function (_a) {
|
|
201
|
-
var _b = __read(_a, 1), entry = _b[0];
|
|
202
|
-
var isIntersecting = entry.isIntersecting;
|
|
203
|
-
if (isIntersecting) {
|
|
204
|
-
animation.value = 1;
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
if (direction === 'both')
|
|
208
|
-
animation.value = 0;
|
|
209
|
-
}
|
|
210
|
-
}, {
|
|
211
|
-
root: null,
|
|
212
|
-
threshold: threshold,
|
|
213
|
-
});
|
|
214
|
-
if (_scrollableBlock) {
|
|
215
|
-
observer.observe(_scrollableBlock);
|
|
216
|
-
}
|
|
217
|
-
return function () {
|
|
218
|
-
if (_scrollableBlock) {
|
|
219
|
-
observer.unobserve(_scrollableBlock);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
}, []);
|
|
223
|
-
return React.createElement("div", { ref: scrollableBlockRef }, children && children(animation));
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* MountedBlock handles mounting and unmounting of a component
|
|
227
|
-
* @props - state: boolean, config: InnerUseMountedValueConfig
|
|
228
|
-
* @children - (animation: { value: TransitionValue }) => React.ReactNode
|
|
169
|
+
* MountedBlock - Higher order component which handles mounting and unmounting of a component.
|
|
170
|
+
* @prop { boolean } state - Boolean indicating the component should mount or unmount.
|
|
171
|
+
* @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
|
|
172
|
+
* @prop { UseMountedValueConfig } config - Animation configuration.
|
|
229
173
|
*/
|
|
230
174
|
var MountedBlock = function (_a) {
|
|
231
175
|
var state = _a.state, children = _a.children, config = _a.config;
|
|
@@ -243,9 +187,25 @@ var getInitialConfig = function (animationType) {
|
|
|
243
187
|
return { mass: 1, friction: 8, tension: 250 };
|
|
244
188
|
case 'bounce':
|
|
245
189
|
return { duration: 500, easing: reMotion.Easing.bounce };
|
|
190
|
+
case 'power1':
|
|
191
|
+
return { duration: 500, easing: reMotion.Easing.bezier(0.17, 0.42, 0.51, 0.97) };
|
|
192
|
+
case 'power2':
|
|
193
|
+
return { duration: 500, easing: reMotion.Easing.bezier(0.07, 0.11, 0.13, 1) };
|
|
194
|
+
case 'power3':
|
|
195
|
+
return { duration: 500, easing: reMotion.Easing.bezier(0.09, 0.7, 0.16, 1.04) };
|
|
196
|
+
case 'power4':
|
|
197
|
+
return { duration: 500, easing: reMotion.Easing.bezier(0.05, 0.54, 0, 1.03) };
|
|
198
|
+
case 'linear':
|
|
199
|
+
return { duration: 500, easing: reMotion.Easing.linear };
|
|
200
|
+
case 'easein':
|
|
201
|
+
return { duration: 500, easing: reMotion.Easing.in(reMotion.Easing.ease) };
|
|
202
|
+
case 'easeout':
|
|
203
|
+
return { duration: 500, easing: reMotion.Easing.out(reMotion.Easing.ease) };
|
|
204
|
+
case 'easeinout':
|
|
205
|
+
return { duration: 500, easing: reMotion.Easing.inOut(reMotion.Easing.ease) };
|
|
246
206
|
case 'ease':
|
|
247
207
|
default:
|
|
248
|
-
return { mass: 1, friction:
|
|
208
|
+
return { mass: 1, friction: 34, tension: 290 };
|
|
249
209
|
}
|
|
250
210
|
};
|
|
251
211
|
|
|
@@ -255,55 +215,95 @@ var AnimationConfigUtils = {
|
|
|
255
215
|
EASE: getInitialConfig('ease'),
|
|
256
216
|
STIFF: getInitialConfig('stiff'),
|
|
257
217
|
WOOBLE: getInitialConfig('wooble'),
|
|
218
|
+
EASE_IN: getInitialConfig('easein'),
|
|
219
|
+
EASE_OUT: getInitialConfig('easeout'),
|
|
220
|
+
EASE_IN_OUT: getInitialConfig('easeinout'),
|
|
221
|
+
POWER1: getInitialConfig('power1'),
|
|
222
|
+
POWER2: getInitialConfig('power2'),
|
|
223
|
+
POWER3: getInitialConfig('power3'),
|
|
224
|
+
POWER4: getInitialConfig('power4'),
|
|
225
|
+
LINEAR: getInitialConfig('linear'),
|
|
258
226
|
};
|
|
259
227
|
|
|
260
228
|
/**
|
|
261
|
-
*
|
|
229
|
+
* `useAnimatedValue` returns an animation value with `.value` and `.currentValue` property which is
|
|
230
|
+
* initialized when passed to argument (`initialValue`). The retured value persist until the lifetime of
|
|
231
|
+
* a component. It doesnot cast any re-renders which can is very good for performance optimization.
|
|
232
|
+
* @param { string | number } initialValue - Initial value
|
|
233
|
+
* @param { UseAnimatedValueConfig } config - Animation configuration object.
|
|
262
234
|
*/
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return function () {
|
|
269
|
-
domTargets.forEach(function (target) {
|
|
270
|
-
target.removeEventListener(event, callback, capture);
|
|
271
|
-
});
|
|
235
|
+
function useAnimatedValue(initialValue, config) {
|
|
236
|
+
var _a = __read(reMotion.useTransition(initialValue, __assign(__assign({}, AnimationConfigUtils.EASE), config)), 2), animation = _a[0], setAnimation = _a[1];
|
|
237
|
+
var targetObject = {
|
|
238
|
+
value: animation,
|
|
239
|
+
currentValue: animation.get(),
|
|
272
240
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
var subscribers = new Map();
|
|
279
|
-
events.forEach(function (_a) {
|
|
280
|
-
var _b = __read(_a, 3), event = _b[0], callback = _b[1], _c = _b[2], capture = _c === void 0 ? false : _c;
|
|
281
|
-
subscribers.set(event, attachEvent(domTargets, event, callback, capture));
|
|
282
|
-
});
|
|
283
|
-
return function (eventKeys) {
|
|
284
|
-
var e_1, _a;
|
|
285
|
-
try {
|
|
286
|
-
for (var _b = __values(subscribers.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
287
|
-
var _d = __read(_c.value, 2), eventKey = _d[0], subscriber = _d[1];
|
|
288
|
-
if (!eventKeys) {
|
|
289
|
-
subscriber();
|
|
290
|
-
return;
|
|
241
|
+
return new Proxy(targetObject, {
|
|
242
|
+
set: function (_, key, value) {
|
|
243
|
+
if (key === 'value') {
|
|
244
|
+
if (typeof value === 'number' || typeof value === 'string') {
|
|
245
|
+
setAnimation({ toValue: value });
|
|
291
246
|
}
|
|
292
|
-
if (
|
|
293
|
-
|
|
247
|
+
else if (typeof value === 'object' || typeof value === 'function') {
|
|
248
|
+
setAnimation(value);
|
|
294
249
|
}
|
|
250
|
+
return true;
|
|
295
251
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
252
|
+
throw new Error('You cannot set any other property to animation node.');
|
|
253
|
+
},
|
|
254
|
+
get: function (_, key) {
|
|
255
|
+
if (key === 'value') {
|
|
256
|
+
return animation;
|
|
301
257
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
258
|
+
if (key === 'currentValue') {
|
|
259
|
+
return animation.get();
|
|
260
|
+
}
|
|
261
|
+
throw new Error('You cannot access any other property from animation node.');
|
|
262
|
+
},
|
|
263
|
+
});
|
|
305
264
|
}
|
|
306
265
|
|
|
266
|
+
/**
|
|
267
|
+
* ScrollableBlock - Higher order component to handle the entrance or exit animation
|
|
268
|
+
* of a component when it enters or exit the viewport. Accepts child as a function with
|
|
269
|
+
* `AnimatedValue` as its first argument which can be interpolated on input range [0, 1]
|
|
270
|
+
* @prop { function } children - child as a function with `AnimatedValue` as its first argument.
|
|
271
|
+
* @prop { 'single' | 'both' } direction - single applies animation on enter once, both applies on enter and exit.
|
|
272
|
+
* @prop { number } threshold - should be in range 0 to 1 which equivalent to `IntersectionObserver` threshold.
|
|
273
|
+
* @prop { UseAnimatedValueConfig } animationConfig - Animation config
|
|
274
|
+
*/
|
|
275
|
+
var ScrollableBlock = function (props) {
|
|
276
|
+
var children = props.children, _a = props.direction, direction = _a === void 0 ? 'single' : _a, animationConfig = props.animationConfig, _b = props.threshold, threshold = _b === void 0 ? 0.2 : _b;
|
|
277
|
+
var scrollableBlockRef = React.useRef(null);
|
|
278
|
+
var animation = useAnimatedValue(0, animationConfig); // 0: not intersecting | 1: intersecting
|
|
279
|
+
React.useEffect(function () {
|
|
280
|
+
var _scrollableBlock = scrollableBlockRef.current;
|
|
281
|
+
var observer = new IntersectionObserver(function (_a) {
|
|
282
|
+
var _b = __read(_a, 1), entry = _b[0];
|
|
283
|
+
var isIntersecting = entry.isIntersecting;
|
|
284
|
+
if (isIntersecting) {
|
|
285
|
+
animation.value = 1;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
if (direction === 'both')
|
|
289
|
+
animation.value = 0;
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
root: null,
|
|
293
|
+
threshold: threshold,
|
|
294
|
+
});
|
|
295
|
+
if (_scrollableBlock) {
|
|
296
|
+
observer.observe(_scrollableBlock);
|
|
297
|
+
}
|
|
298
|
+
return function () {
|
|
299
|
+
if (_scrollableBlock) {
|
|
300
|
+
observer.unobserve(_scrollableBlock);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}, []);
|
|
304
|
+
return (React.createElement("div", { ref: scrollableBlockRef }, children && children({ value: animation.value })));
|
|
305
|
+
};
|
|
306
|
+
|
|
307
307
|
/**
|
|
308
308
|
* bin(booleanValue)
|
|
309
309
|
* returns 1 if booleanValue == true and 0 if booleanValue == false
|
|
@@ -396,6 +396,65 @@ function move(array, moveIndex, toIndex) {
|
|
|
396
396
|
return array;
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
/**
|
|
400
|
+
* TransitionBlock - Higher order component which animates on state change.
|
|
401
|
+
* @prop { boolean } state - Boolean indicating the current state of animation, usually `false = 0 and true = 1`.
|
|
402
|
+
* @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
|
|
403
|
+
* @prop { UseAnimatedValueConfig } config - Animation configuration.
|
|
404
|
+
*/
|
|
405
|
+
var TransitionBlock = function (_a) {
|
|
406
|
+
var state = _a.state, children = _a.children, config = _a.config;
|
|
407
|
+
var amv = useAnimatedValue(bin(state), config);
|
|
408
|
+
return React.createElement(React.Fragment, null, children({ value: amv.value }));
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Attach single document / window event / HTMLElement
|
|
413
|
+
*/
|
|
414
|
+
function attachEvent(domTargets, event, callback, capture) {
|
|
415
|
+
if (capture === void 0) { capture = false; }
|
|
416
|
+
domTargets.forEach(function (target) {
|
|
417
|
+
target.addEventListener(event, callback, capture);
|
|
418
|
+
});
|
|
419
|
+
return function () {
|
|
420
|
+
domTargets.forEach(function (target) {
|
|
421
|
+
target.removeEventListener(event, callback, capture);
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Attach multiple document / window event / HTMLElement
|
|
427
|
+
*/
|
|
428
|
+
function attachEvents(domTargets, events) {
|
|
429
|
+
var subscribers = new Map();
|
|
430
|
+
events.forEach(function (_a) {
|
|
431
|
+
var _b = __read(_a, 3), event = _b[0], callback = _b[1], _c = _b[2], capture = _c === void 0 ? false : _c;
|
|
432
|
+
subscribers.set(event, attachEvent(domTargets, event, callback, capture));
|
|
433
|
+
});
|
|
434
|
+
return function (eventKeys) {
|
|
435
|
+
var e_1, _a;
|
|
436
|
+
try {
|
|
437
|
+
for (var _b = __values(subscribers.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
438
|
+
var _d = __read(_c.value, 2), eventKey = _d[0], subscriber = _d[1];
|
|
439
|
+
if (!eventKeys) {
|
|
440
|
+
subscriber();
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (eventKeys.indexOf(eventKey) !== -1) {
|
|
444
|
+
subscriber();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
449
|
+
finally {
|
|
450
|
+
try {
|
|
451
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
452
|
+
}
|
|
453
|
+
finally { if (e_1) throw e_1.error; }
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
|
|
399
458
|
var withDefault = function (x, y) {
|
|
400
459
|
return { x: x, y: y };
|
|
401
460
|
};
|
|
@@ -599,15 +658,15 @@ var MouseMoveGesture = /** @class */ (function (_super) {
|
|
|
599
658
|
// initialize the events
|
|
600
659
|
MouseMoveGesture.prototype._initEvents = function () {
|
|
601
660
|
if (this.targetElement) {
|
|
602
|
-
this._subscribe = attachEvents([this.targetElement], [[
|
|
661
|
+
this._subscribe = attachEvents([this.targetElement], [['mousemove', this.onMouseMove.bind(this)]]);
|
|
603
662
|
}
|
|
604
663
|
else if (this.targetElements.length > 0) {
|
|
605
664
|
this._subscribe = attachEvents(this.targetElements, [
|
|
606
|
-
[
|
|
665
|
+
['mousemove', this.onMouseMove.bind(this)],
|
|
607
666
|
]);
|
|
608
667
|
}
|
|
609
668
|
else {
|
|
610
|
-
this._subscribe = attachEvents([window], [[
|
|
669
|
+
this._subscribe = attachEvents([window], [['mousemove', this.onMouseMove.bind(this)]]);
|
|
611
670
|
}
|
|
612
671
|
};
|
|
613
672
|
MouseMoveGesture.prototype._handleCallback = function () {
|
|
@@ -683,10 +742,10 @@ var ScrollGesture = /** @class */ (function (_super) {
|
|
|
683
742
|
// initialize the events
|
|
684
743
|
ScrollGesture.prototype._initEvents = function () {
|
|
685
744
|
if (this.targetElement) {
|
|
686
|
-
this._subscribe = attachEvents([this.targetElement], [[
|
|
745
|
+
this._subscribe = attachEvents([this.targetElement], [['scroll', this.scrollElementListener.bind(this)]]);
|
|
687
746
|
}
|
|
688
747
|
else {
|
|
689
|
-
this._subscribe = attachEvents([window], [[
|
|
748
|
+
this._subscribe = attachEvents([window], [['scroll', this.scrollListener.bind(this)]]);
|
|
690
749
|
}
|
|
691
750
|
};
|
|
692
751
|
ScrollGesture.prototype._handleCallback = function () {
|
|
@@ -771,7 +830,7 @@ var WheelGesture = /** @class */ (function (_super) {
|
|
|
771
830
|
// initialize the events
|
|
772
831
|
WheelGesture.prototype._initEvents = function () {
|
|
773
832
|
if (this.targetElement) {
|
|
774
|
-
this._subscribe = attachEvents([this.targetElement], [[
|
|
833
|
+
this._subscribe = attachEvents([this.targetElement], [['wheel', this.onWheel.bind(this)]]);
|
|
775
834
|
}
|
|
776
835
|
};
|
|
777
836
|
WheelGesture.prototype._handleCallback = function () {
|
|
@@ -915,22 +974,22 @@ var useRecognizer = function (handlers) {
|
|
|
915
974
|
|
|
916
975
|
function useDrag(callback, config) {
|
|
917
976
|
var gesture = React.useRef(new DragGesture()).current;
|
|
918
|
-
return useRecognizer([[
|
|
977
|
+
return useRecognizer([['drag', gesture, callback, config]]);
|
|
919
978
|
}
|
|
920
979
|
|
|
921
980
|
function useMouseMove(callback) {
|
|
922
981
|
var gesture = React.useRef(new MouseMoveGesture()).current;
|
|
923
|
-
return useRecognizer([[
|
|
982
|
+
return useRecognizer([['move', gesture, callback]]);
|
|
924
983
|
}
|
|
925
984
|
|
|
926
985
|
function useScroll(callback) {
|
|
927
986
|
var gesture = React.useRef(new ScrollGesture()).current;
|
|
928
|
-
return useRecognizer([[
|
|
987
|
+
return useRecognizer([['scroll', gesture, callback]]);
|
|
929
988
|
}
|
|
930
989
|
|
|
931
990
|
function useWheel(callback) {
|
|
932
991
|
var gesture = React.useRef(new WheelGesture()).current;
|
|
933
|
-
return useRecognizer([[
|
|
992
|
+
return useRecognizer([['wheel', gesture, callback]]);
|
|
934
993
|
}
|
|
935
994
|
|
|
936
995
|
function useGesture(_a) {
|
|
@@ -940,10 +999,10 @@ function useGesture(_a) {
|
|
|
940
999
|
var scrollGesture = React.useRef(new ScrollGesture()).current;
|
|
941
1000
|
var mouseMoveGesture = React.useRef(new MouseMoveGesture()).current;
|
|
942
1001
|
return useRecognizer([
|
|
943
|
-
[
|
|
944
|
-
[
|
|
945
|
-
[
|
|
946
|
-
[
|
|
1002
|
+
['drag', dragGesture, onDrag],
|
|
1003
|
+
['wheel', wheelGesture, onWheel],
|
|
1004
|
+
['scroll', scrollGesture, onScroll],
|
|
1005
|
+
['move', mouseMoveGesture, onMouseMove],
|
|
947
1006
|
]);
|
|
948
1007
|
}
|
|
949
1008
|
|
|
@@ -1122,16 +1181,23 @@ Object.defineProperty(exports, 'interpolate', {
|
|
|
1122
1181
|
return reMotion.interpolate;
|
|
1123
1182
|
}
|
|
1124
1183
|
});
|
|
1184
|
+
Object.defineProperty(exports, 'makeAnimatedComponent', {
|
|
1185
|
+
enumerable: true,
|
|
1186
|
+
get: function () {
|
|
1187
|
+
return reMotion.makeAnimatedComponent;
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1125
1190
|
exports.AnimatedBlock = AnimatedBlock;
|
|
1126
1191
|
exports.AnimatedImage = AnimatedImage;
|
|
1127
1192
|
exports.AnimatedInline = AnimatedInline;
|
|
1128
1193
|
exports.AnimationConfigUtils = AnimationConfigUtils;
|
|
1129
1194
|
exports.MountedBlock = MountedBlock;
|
|
1130
1195
|
exports.ScrollableBlock = ScrollableBlock;
|
|
1196
|
+
exports.TransitionBlock = TransitionBlock;
|
|
1131
1197
|
exports.bInterpolate = bInterpolate;
|
|
1132
1198
|
exports.bin = bin;
|
|
1133
1199
|
exports.clamp = clamp;
|
|
1134
|
-
exports.
|
|
1200
|
+
exports.delay = delay;
|
|
1135
1201
|
exports.mix = mix;
|
|
1136
1202
|
exports.move = move;
|
|
1137
1203
|
exports.rubberClamp = rubberClamp;
|