react-native-reanimated 2.3.1 → 2.4.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/android/build.gradle +3 -3
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +4 -0
- package/ios/native/NativeMethods.h +1 -1
- package/ios/native/NativeProxy.mm +10 -2
- package/lib/{Animated.js → src/Animated.js} +0 -0
- package/lib/{ConfigHelper.js → src/ConfigHelper.js} +0 -0
- package/lib/{ReanimatedEventEmitter.js → src/ReanimatedEventEmitter.js} +0 -0
- package/lib/{ReanimatedModule.js → src/ReanimatedModule.js} +0 -0
- package/lib/{ReanimatedModule.macos.js → src/ReanimatedModule.macos.js} +0 -0
- package/lib/{ReanimatedModule.native.js → src/ReanimatedModule.native.js} +0 -0
- package/lib/{ReanimatedModule.windows.js → src/ReanimatedModule.windows.js} +0 -0
- package/lib/{ReanimatedModuleCompat.js → src/ReanimatedModuleCompat.js} +0 -0
- package/lib/{__mocks__ → src/__mocks__}/ReanimatedEventEmitter.js +0 -0
- package/lib/{__mocks__ → src/__mocks__}/ReanimatedModule.native.js +0 -0
- package/lib/{createAnimatedComponent.js → src/createAnimatedComponent.js} +0 -0
- package/lib/{index.js → src/index.js} +0 -0
- package/lib/{reanimated1 → src/reanimated1}/Easing.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/SpringConfig.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/Transitioning.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/Animation.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/SpringUtils.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/backwardCompatibleAnimWrapper.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/decay.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/spring.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/timing.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/base.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedAlways.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBezier.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBlock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCall.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCallFunc.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClockTest.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedConcat.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCond.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedDebug.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedEvent.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedFunction.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedNode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedOperator.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedParam.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedProps.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedSet.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStartClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStopClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStyle.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedTransform.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/Core.test.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/InternalAnimatedValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/__mocks__/AnimatedProps.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/createEventObjectProxyPolyfill.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/__mocks__/evaluateOnce.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/acc.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/color.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/diff.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/diffClamp.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/evaluateOnce.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/index.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/interpolate.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/interpolateColors.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/onChange.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/useCode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/index.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/operators.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/useValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/val.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/Bezier.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/Colors.js +1 -97
- package/lib/{reanimated2 → src/reanimated2}/Easing.js +5 -0
- package/lib/{reanimated2 → src/reanimated2}/NativeMethods.js +15 -5
- package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/NativeReanimated.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/index.js +2 -2
- package/lib/{reanimated2 → src/reanimated2}/PlatformChecker.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/PropAdapters.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/UpdateProps.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/ViewDescriptorsSet.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/WorkletEventHandler.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/MutableValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.native.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/decay.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/delay.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/repeat.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/sequence.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/spring.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/styleAnimation.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/timing.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/util.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/component/FlatList.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/component/WrappedComponents.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/component/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/core.js +5 -3
- package/lib/{reanimated2 → src/reanimated2}/globals.d.ts +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/Hooks.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedGestureHandler.js +1 -2
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedReaction.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedRef.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedScrollHandler.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedStyle.js +31 -14
- package/lib/{reanimated2 → src/reanimated2}/hook/useDerivedValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useSharedValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/utils.js +14 -11
- package/lib/{reanimated2 → src/reanimated2}/index.js +2 -0
- package/lib/src/reanimated2/interpolateColor.js +98 -0
- package/lib/{reanimated2 → src/reanimated2}/interpolation.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/jestUtils.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/JSReanimated.js +1 -1
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/Mapper.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MapperRegistry.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MutableValue.js +0 -0
- package/lib/{reanimated2/layoutReanimation/animationBuilder → src/reanimated2/js-reanimated}/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/LayoutAnimationRepository.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/Keyframe.js +0 -0
- package/lib/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Bounce.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Default.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Fade.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Flip.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Roll.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Rotate.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Slide.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Stretch.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Zoom.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/mock.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.web.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/utils.js +0 -0
- package/lib/{setAndForwardRef.js → src/setAndForwardRef.js} +0 -0
- package/mock.js +1 -0
- package/package.json +5 -3
- package/plugin.js +1 -0
- package/react-native-reanimated.d.ts +55 -1
- package/src/reanimated2/Colors.ts +6 -150
- package/src/reanimated2/Easing.ts +11 -0
- package/src/reanimated2/NativeMethods.ts +19 -6
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +1 -0
- package/src/reanimated2/NativeReanimated/index.ts +2 -2
- package/src/reanimated2/animation/commonTypes.ts +44 -40
- package/src/reanimated2/animation/decay.ts +1 -1
- package/src/reanimated2/animation/delay.ts +2 -16
- package/src/reanimated2/animation/index.ts +7 -8
- package/src/reanimated2/animation/repeat.ts +2 -12
- package/src/reanimated2/animation/sequence.ts +3 -10
- package/src/reanimated2/animation/spring.ts +1 -1
- package/src/reanimated2/animation/styleAnimation.ts +1 -18
- package/src/reanimated2/animation/timing.ts +1 -1
- package/src/reanimated2/animation/util.ts +12 -9
- package/src/reanimated2/commonTypes.ts +48 -1
- package/src/reanimated2/core.ts +6 -6
- package/src/reanimated2/hook/commonTypes.ts +5 -0
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
- package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
- package/src/reanimated2/hook/utils.ts +18 -17
- package/src/reanimated2/index.ts +2 -0
- package/src/reanimated2/interpolateColor.ts +178 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +3 -4
- package/src/reanimated2/js-reanimated/Mapper.ts +1 -1
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +1 -1
- package/src/reanimated2/js-reanimated/commonTypes.ts +51 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +6 -2
- package/src/reanimated2/utils.ts +1 -1
|
@@ -164,7 +164,11 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
164
164
|
else {
|
|
165
165
|
state.isAnimationCancelled = true;
|
|
166
166
|
state.animations = [];
|
|
167
|
-
|
|
167
|
+
const diff = styleDiff(oldValues, newValues);
|
|
168
|
+
state.last = Object.assign({}, oldValues, newValues);
|
|
169
|
+
if (diff) {
|
|
170
|
+
updateProps(viewDescriptors, newValues, maybeViewRef);
|
|
171
|
+
}
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
174
|
function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsActive, animatedStyle, adapters = []) {
|
|
@@ -305,10 +309,10 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
305
309
|
const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;
|
|
306
310
|
useEffect(() => {
|
|
307
311
|
let fun;
|
|
308
|
-
let
|
|
312
|
+
let updaterFn = updater;
|
|
309
313
|
let optimalization = updater.__optimalization;
|
|
310
314
|
if (adapters) {
|
|
311
|
-
|
|
315
|
+
updaterFn = () => {
|
|
312
316
|
'worklet';
|
|
313
317
|
const newValues = updater();
|
|
314
318
|
adaptersArray.forEach((adapter) => {
|
|
@@ -317,27 +321,40 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
317
321
|
return newValues;
|
|
318
322
|
};
|
|
319
323
|
}
|
|
320
|
-
if (canApplyOptimalisation(
|
|
321
|
-
if (hasColorProps(
|
|
322
|
-
|
|
324
|
+
if (canApplyOptimalisation(updaterFn) && !shouldBeUseWeb()) {
|
|
325
|
+
if (hasColorProps(updaterFn())) {
|
|
326
|
+
updaterFn = () => {
|
|
327
|
+
'worklet';
|
|
328
|
+
const newValues = updaterFn();
|
|
329
|
+
const oldValues = remoteState.last;
|
|
330
|
+
const diff = styleDiff(oldValues, newValues);
|
|
331
|
+
remoteState.last = Object.assign({}, oldValues, newValues);
|
|
332
|
+
parseColors(diff);
|
|
333
|
+
return diff;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
updaterFn = () => {
|
|
323
338
|
'worklet';
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
339
|
+
const newValues = updaterFn();
|
|
340
|
+
const oldValues = remoteState.last;
|
|
341
|
+
const diff = styleDiff(oldValues, newValues);
|
|
342
|
+
remoteState.last = Object.assign({}, oldValues, newValues);
|
|
343
|
+
return diff;
|
|
327
344
|
};
|
|
328
345
|
}
|
|
329
346
|
}
|
|
330
347
|
else if (!shouldBeUseWeb()) {
|
|
331
348
|
optimalization = 0;
|
|
332
|
-
|
|
349
|
+
updaterFn = () => {
|
|
333
350
|
'worklet';
|
|
334
|
-
const style =
|
|
351
|
+
const style = updaterFn();
|
|
335
352
|
parseColors(style);
|
|
336
353
|
return style;
|
|
337
354
|
};
|
|
338
355
|
}
|
|
339
356
|
if (typeof updater.__optimalization !== undefined) {
|
|
340
|
-
|
|
357
|
+
updaterFn.__optimalization = optimalization;
|
|
341
358
|
}
|
|
342
359
|
if (isJest()) {
|
|
343
360
|
fun = () => {
|
|
@@ -348,10 +365,10 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
348
365
|
else {
|
|
349
366
|
fun = () => {
|
|
350
367
|
'worklet';
|
|
351
|
-
styleUpdater(sharableViewDescriptors,
|
|
368
|
+
styleUpdater(sharableViewDescriptors, updaterFn, remoteState, maybeViewRef, animationsActive);
|
|
352
369
|
};
|
|
353
370
|
}
|
|
354
|
-
const mapperId = startMapper(fun, inputs, [],
|
|
371
|
+
const mapperId = startMapper(fun, inputs, [], updaterFn,
|
|
355
372
|
// TODO fix this
|
|
356
373
|
sharableViewDescriptors);
|
|
357
374
|
return () => {
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { processColor } from '../Colors';
|
|
3
3
|
import { makeRemote } from '../core';
|
|
4
|
-
import { isWeb } from '../PlatformChecker';
|
|
4
|
+
import { isWeb, isJest } from '../PlatformChecker';
|
|
5
5
|
import { colorProps } from '../UpdateProps';
|
|
6
6
|
import WorkletEventHandler from '../WorkletEventHandler';
|
|
7
7
|
export function useEvent(handler, eventNames = [], rebuild = false) {
|
|
@@ -36,7 +36,7 @@ export function useHandler(handlers, dependencies) {
|
|
|
36
36
|
dependencies = buildDependencies(dependencies, handlers);
|
|
37
37
|
const doDependenciesDiffer = !areDependenciesEqual(dependencies, savedDependencies);
|
|
38
38
|
initRef.current.savedDependencies = dependencies;
|
|
39
|
-
const useWeb = isWeb();
|
|
39
|
+
const useWeb = isWeb() || isJest();
|
|
40
40
|
return { context, doDependenciesDiffer, useWeb };
|
|
41
41
|
}
|
|
42
42
|
// builds one big hash from multiple worklets' hashes
|
|
@@ -95,7 +95,12 @@ export function parseColors(updates) {
|
|
|
95
95
|
'worklet';
|
|
96
96
|
for (const key in updates) {
|
|
97
97
|
if (colorProps.indexOf(key) !== -1) {
|
|
98
|
-
|
|
98
|
+
// value could be an animation in which case processColor will recognize it and will return undefined
|
|
99
|
+
// -> in such a case we don't want to override style of that key
|
|
100
|
+
const processedColor = processColor(updates[key]);
|
|
101
|
+
if (processedColor !== undefined) {
|
|
102
|
+
updates[key] = processedColor;
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
}
|
|
@@ -132,24 +137,22 @@ export function isAnimated(prop) {
|
|
|
132
137
|
export function styleDiff(oldStyle, newStyle) {
|
|
133
138
|
'worklet';
|
|
134
139
|
const diff = {};
|
|
135
|
-
|
|
140
|
+
for (const key in oldStyle) {
|
|
136
141
|
if (newStyle[key] === undefined) {
|
|
137
142
|
diff[key] = null;
|
|
138
143
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
144
|
+
}
|
|
145
|
+
for (const key in newStyle) {
|
|
141
146
|
const value = newStyle[key];
|
|
142
147
|
const oldValue = oldStyle[key];
|
|
143
148
|
if (isAnimated(value)) {
|
|
144
149
|
// do nothing
|
|
145
|
-
|
|
150
|
+
continue;
|
|
146
151
|
}
|
|
147
|
-
if (oldValue !== value
|
|
148
|
-
JSON.stringify(oldValue) !== JSON.stringify(value)) {
|
|
149
|
-
// I'd use deep equal here but that'd take additional work and this was easier
|
|
152
|
+
if (oldValue !== value) {
|
|
150
153
|
diff[key] = value;
|
|
151
154
|
}
|
|
152
|
-
}
|
|
155
|
+
}
|
|
153
156
|
return diff;
|
|
154
157
|
}
|
|
155
158
|
export function getStyleWithoutAnimations(newStyle) {
|
|
@@ -2,9 +2,11 @@ export * from './core';
|
|
|
2
2
|
export * from './hook';
|
|
3
3
|
export * from './animation';
|
|
4
4
|
export * from './interpolation';
|
|
5
|
+
export * from './interpolateColor';
|
|
5
6
|
export * from './Easing';
|
|
6
7
|
export * from './NativeMethods';
|
|
7
8
|
export * from './Colors';
|
|
8
9
|
export * from './PropAdapters';
|
|
9
10
|
export * from './layoutReanimation';
|
|
10
11
|
export * from './utils';
|
|
12
|
+
export * from './commonTypes';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { hsvToColor, RGBtoHSV, rgbaColor, processColor, red, green, blue, opacity, } from './Colors';
|
|
2
|
+
import { makeMutable } from './core';
|
|
3
|
+
import { interpolate } from './interpolation';
|
|
4
|
+
// @ts-ignore JS file
|
|
5
|
+
import { Extrapolate } from '../reanimated1/derived';
|
|
6
|
+
import { useSharedValue } from './hook/useSharedValue';
|
|
7
|
+
const interpolateColorsHSV = (value, inputRange, colors) => {
|
|
8
|
+
'worklet';
|
|
9
|
+
const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
|
|
10
|
+
const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
|
|
11
|
+
const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
|
|
12
|
+
return hsvToColor(h, s, v);
|
|
13
|
+
};
|
|
14
|
+
const interpolateColorsRGB = (value, inputRange, colors) => {
|
|
15
|
+
'worklet';
|
|
16
|
+
const r = interpolate(value, inputRange, colors.r, Extrapolate.CLAMP);
|
|
17
|
+
const g = interpolate(value, inputRange, colors.g, Extrapolate.CLAMP);
|
|
18
|
+
const b = interpolate(value, inputRange, colors.b, Extrapolate.CLAMP);
|
|
19
|
+
const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
|
|
20
|
+
return rgbaColor(r, g, b, a);
|
|
21
|
+
};
|
|
22
|
+
const getInterpolateRGB = (colors) => {
|
|
23
|
+
'worklet';
|
|
24
|
+
const r = [];
|
|
25
|
+
const g = [];
|
|
26
|
+
const b = [];
|
|
27
|
+
const a = [];
|
|
28
|
+
for (let i = 0; i < colors.length; ++i) {
|
|
29
|
+
const color = colors[i];
|
|
30
|
+
const proocessedColor = processColor(color);
|
|
31
|
+
// explicit check in case if processedColor is 0
|
|
32
|
+
if (proocessedColor !== null && proocessedColor !== undefined) {
|
|
33
|
+
r.push(red(proocessedColor));
|
|
34
|
+
g.push(green(proocessedColor));
|
|
35
|
+
b.push(blue(proocessedColor));
|
|
36
|
+
a.push(opacity(proocessedColor));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { r, g, b, a };
|
|
40
|
+
};
|
|
41
|
+
const getInterpolateHSV = (colors) => {
|
|
42
|
+
'worklet';
|
|
43
|
+
const h = [];
|
|
44
|
+
const s = [];
|
|
45
|
+
const v = [];
|
|
46
|
+
for (let i = 0; i < colors.length; ++i) {
|
|
47
|
+
const color = colors[i];
|
|
48
|
+
const proocessedColor = RGBtoHSV(processColor(color));
|
|
49
|
+
if (proocessedColor) {
|
|
50
|
+
h.push(proocessedColor.h);
|
|
51
|
+
s.push(proocessedColor.s);
|
|
52
|
+
v.push(proocessedColor.v);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { h, s, v };
|
|
56
|
+
};
|
|
57
|
+
export const interpolateColor = (value, inputRange, outputRange, colorSpace = 'RGB') => {
|
|
58
|
+
'worklet';
|
|
59
|
+
if (colorSpace === 'HSV') {
|
|
60
|
+
return interpolateColorsHSV(value, inputRange, getInterpolateHSV(outputRange));
|
|
61
|
+
}
|
|
62
|
+
else if (colorSpace === 'RGB') {
|
|
63
|
+
return interpolateColorsRGB(value, inputRange, getInterpolateRGB(outputRange));
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`);
|
|
66
|
+
};
|
|
67
|
+
export var ColorSpace;
|
|
68
|
+
(function (ColorSpace) {
|
|
69
|
+
ColorSpace[ColorSpace["RGB"] = 0] = "RGB";
|
|
70
|
+
ColorSpace[ColorSpace["HSV"] = 1] = "HSV";
|
|
71
|
+
})(ColorSpace || (ColorSpace = {}));
|
|
72
|
+
export function useInterpolateConfig(inputRange, outputRange, colorSpace = ColorSpace.RGB) {
|
|
73
|
+
return useSharedValue({
|
|
74
|
+
inputRange,
|
|
75
|
+
outputRange,
|
|
76
|
+
colorSpace,
|
|
77
|
+
cache: makeMutable(null),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export const interpolateSharableColor = (value, interpolateConfig) => {
|
|
81
|
+
'worklet';
|
|
82
|
+
let colors = interpolateConfig.value.cache.value;
|
|
83
|
+
if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {
|
|
84
|
+
if (!colors) {
|
|
85
|
+
colors = getInterpolateRGB(interpolateConfig.value.outputRange);
|
|
86
|
+
interpolateConfig.value.cache.value = colors;
|
|
87
|
+
}
|
|
88
|
+
return interpolateColorsRGB(value, interpolateConfig.value.inputRange, colors);
|
|
89
|
+
}
|
|
90
|
+
else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {
|
|
91
|
+
if (!colors) {
|
|
92
|
+
colors = getInterpolateHSV(interpolateConfig.value.outputRange);
|
|
93
|
+
interpolateConfig.value.cache.value = colors;
|
|
94
|
+
}
|
|
95
|
+
return interpolateColorsHSV(value, interpolateConfig.value.inputRange, colors);
|
|
96
|
+
}
|
|
97
|
+
throw new Error(`Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`);
|
|
98
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapperRegistry from './MapperRegistry';
|
|
2
|
-
import MutableValue from './MutableValue';
|
|
3
2
|
import Mapper from './Mapper';
|
|
3
|
+
import MutableValue from './MutableValue';
|
|
4
4
|
import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
|
|
5
5
|
export default class JSReanimated extends NativeReanimated {
|
|
6
6
|
constructor() {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js
RENAMED
|
File without changes
|
|
File without changes
|
package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js
RENAMED
|
File without changes
|
|
File without changes
|
package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/mock.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-reanimated",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "More powerful alternative to Animated library for React Native.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "node node_modules/react-native/local-cli/cli.js start",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"type:generate:tsc": "yarn tsc",
|
|
25
25
|
"type:generate:remove.ts": "find ./lib -type f -name \"*.ts\" -and -not -name \"*.d.ts\" -delete",
|
|
26
26
|
"type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete",
|
|
27
|
-
"prepare": "husky install"
|
|
27
|
+
"prepare": "husky install",
|
|
28
|
+
"circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular ./src"
|
|
28
29
|
},
|
|
29
30
|
"main": "lib/Animated.js",
|
|
30
31
|
"module": "lib/Animated",
|
|
@@ -114,9 +115,10 @@
|
|
|
114
115
|
"husky": "^7.0.0",
|
|
115
116
|
"jest": "^26.6.3",
|
|
116
117
|
"lint-staged": "^11.2.0",
|
|
118
|
+
"madge": "^5.0.1",
|
|
117
119
|
"prettier": "^2.2.1",
|
|
118
120
|
"react": "17.0.2",
|
|
119
|
-
"react-native": "0.67.
|
|
121
|
+
"react-native": "0.67.2",
|
|
120
122
|
"react-native-codegen": "^0.0.7",
|
|
121
123
|
"react-native-gesture-handler": "^1.6.1",
|
|
122
124
|
"react-test-renderer": "17.0.2",
|
package/plugin.js
CHANGED
|
@@ -16,6 +16,7 @@ declare module 'react-native-reanimated' {
|
|
|
16
16
|
TextProps,
|
|
17
17
|
ImageProps,
|
|
18
18
|
ScrollViewProps,
|
|
19
|
+
FlatListProps,
|
|
19
20
|
StyleProp,
|
|
20
21
|
RegisteredStyle,
|
|
21
22
|
ViewStyle,
|
|
@@ -247,20 +248,31 @@ declare module 'react-native-reanimated' {
|
|
|
247
248
|
export class View extends Component<AnimateProps<ViewProps>> {
|
|
248
249
|
getNode(): ReactNativeView;
|
|
249
250
|
}
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
252
|
+
export interface View extends ReactNativeView {}
|
|
250
253
|
export class Text extends Component<AnimateProps<TextProps>> {
|
|
251
254
|
getNode(): ReactNativeText;
|
|
252
255
|
}
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
257
|
+
export interface Text extends ReactNativeText {}
|
|
253
258
|
export class Image extends Component<AnimateProps<ImageProps>> {
|
|
254
259
|
getNode(): ReactNativeImage;
|
|
255
260
|
}
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
262
|
+
export interface Image extends ReactNativeImage {}
|
|
256
263
|
export class ScrollView extends Component<AnimateProps<ScrollViewProps>> {
|
|
257
264
|
getNode(): ReactNativeScrollView;
|
|
258
265
|
}
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
267
|
+
export interface ScrollView extends ReactNativeScrollView {}
|
|
268
|
+
|
|
259
269
|
export class Code extends Component<CodeProps> {}
|
|
260
|
-
export class FlatList extends Component<AnimateProps<
|
|
270
|
+
export class FlatList<T> extends Component<AnimateProps<FlatListProps<T>>> {
|
|
261
271
|
itemLayoutAnimation: ILayoutAnimationBuilder;
|
|
262
272
|
getNode(): ReactNativeFlatList;
|
|
263
273
|
}
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
275
|
+
export interface FlatList<T> extends ReactNativeView<T> {}
|
|
264
276
|
|
|
265
277
|
type Options<P> = {
|
|
266
278
|
setNativeProps: (ref: any, props: P) => void;
|
|
@@ -610,6 +622,42 @@ declare module 'react-native-reanimated' {
|
|
|
610
622
|
colorSpace?: 'RGB' | 'HSV'
|
|
611
623
|
): string | number;
|
|
612
624
|
|
|
625
|
+
export enum ColorSpace {
|
|
626
|
+
RGB = 0,
|
|
627
|
+
HSV = 1,
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export interface InterpolateRGB {
|
|
631
|
+
r: number[];
|
|
632
|
+
g: number[];
|
|
633
|
+
b: number[];
|
|
634
|
+
a: number[];
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export interface InterpolateHSV {
|
|
638
|
+
h: number[];
|
|
639
|
+
s: number[];
|
|
640
|
+
v: number[];
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export interface InterpolateConfig {
|
|
644
|
+
inputRange: readonly number[];
|
|
645
|
+
outputRange: readonly (string | number)[];
|
|
646
|
+
colorSpace: ColorSpace;
|
|
647
|
+
cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export function useInterpolateConfig(
|
|
651
|
+
inputRange: readonly number[],
|
|
652
|
+
outputRange: readonly (string | number)[],
|
|
653
|
+
colorSpace?: ColorSpace
|
|
654
|
+
): SharedValue<InterpolateConfig>;
|
|
655
|
+
|
|
656
|
+
export function interpolateSharableColor(
|
|
657
|
+
value: number,
|
|
658
|
+
interpolateConfig: SharedValue<InterpolateConfig>
|
|
659
|
+
): string | number;
|
|
660
|
+
|
|
613
661
|
export function makeMutable<T>(initialValue: T): SharedValue<T>;
|
|
614
662
|
|
|
615
663
|
type DependencyList = ReadonlyArray<any>;
|
|
@@ -981,6 +1029,12 @@ declare module 'react-native-reanimated' {
|
|
|
981
1029
|
y1: number,
|
|
982
1030
|
x2: number,
|
|
983
1031
|
y2: number
|
|
1032
|
+
): { factory: () => Animated.EasingFunction };
|
|
1033
|
+
bezierFn(
|
|
1034
|
+
x1: number,
|
|
1035
|
+
y1: number,
|
|
1036
|
+
x2: number,
|
|
1037
|
+
y2: number
|
|
984
1038
|
): Animated.EasingFunction;
|
|
985
1039
|
in(easing: Animated.EasingFunction): Animated.EasingFunction;
|
|
986
1040
|
out(easing: Animated.EasingFunction): Animated.EasingFunction;
|