react-native-reanimated 2.9.1 → 2.11.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/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +7 -4
- package/Common/cpp/{headers/AnimatedSensor → AnimatedSensor}/AnimatedSensorModule.h +0 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +2 -0
- package/Common/cpp/{headers/LayoutAnimations → LayoutAnimations}/LayoutAnimationsProxy.h +0 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +40 -0
- package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModule.h +13 -0
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +25 -0
- package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModuleSpec.h +9 -1
- package/Common/cpp/{headers/Registries → Registries}/EventHandlerRegistry.h +0 -0
- package/Common/cpp/Registries/MapperRegistry.cpp +3 -1
- package/Common/cpp/{headers/Registries → Registries}/MapperRegistry.h +0 -0
- package/Common/cpp/Registries/WorkletsCache.cpp +3 -0
- package/Common/cpp/{headers/Registries → Registries}/WorkletsCache.h +0 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/FrozenObject.h +0 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/HostFunctionHandler.h +0 -0
- package/Common/cpp/SharedItems/MutableValue.cpp +2 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/MutableValue.h +0 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/MutableValueSetterProxy.h +0 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/RemoteObject.h +0 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/RuntimeManager.h +0 -0
- package/Common/cpp/SharedItems/ShareableValue.cpp +7 -2
- package/Common/cpp/{headers/SharedItems → SharedItems}/ShareableValue.h +0 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/SharedParent.h +0 -0
- package/Common/cpp/{headers/SharedItems → SharedItems}/ValueWrapper.h +0 -0
- package/Common/cpp/{headers/SpecTools → SpecTools}/ErrorHandler.h +0 -0
- package/Common/cpp/{headers/Tools → Tools}/FeaturesConfig.h +0 -0
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +2 -2
- package/Common/cpp/{headers/Tools → Tools}/JSIStoreValueUser.h +0 -0
- package/Common/cpp/{headers/Tools → Tools}/Mapper.h +0 -0
- package/Common/cpp/{headers/Tools → Tools}/PlatformDepMethodsHolder.h +5 -0
- package/Common/cpp/{headers/Tools → Tools}/ReanimatedHiddenHeaders.h +1 -1
- package/Common/cpp/{headers/Tools → Tools}/RuntimeDecorator.h +0 -0
- package/Common/cpp/{headers/Tools → Tools}/Scheduler.h +0 -0
- package/Common/cpp/Tools/SingleInstanceChecker.h +58 -0
- package/Common/cpp/{headers/Tools → Tools}/WorkletEventHandler.h +0 -0
- package/RNReanimated.podspec +18 -58
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/{7.2 → 7.5.1}/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/{7.2 → 7.5.1}/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/{7.2 → 7.5.1}/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/{7.2 → 7.5.1}/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/CMakeLists.txt +223 -113
- package/android/build.gradle +480 -195
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- 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/android/react-native-reanimated-68-hermes.aar +0 -0
- package/android/react-native-reanimated-68-jsc.aar +0 -0
- package/android/react-native-reanimated-69-hermes.aar +0 -0
- package/android/react-native-reanimated-69-jsc.aar +0 -0
- package/android/react-native-reanimated-70-hermes.aar +0 -0
- package/android/react-native-reanimated-70-jsc.aar +0 -0
- package/{lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts → android/rnVersionPatch/70/.gitkeep} +0 -0
- package/android/src/main/cpp/AndroidErrorHandler.cpp +3 -4
- package/android/src/main/cpp/{headers/AndroidErrorHandler.h → AndroidErrorHandler.h} +1 -4
- package/android/src/main/cpp/AndroidLogger.cpp +4 -1
- package/android/src/main/cpp/{headers/AndroidLogger.h → AndroidLogger.h} +0 -0
- package/android/src/main/cpp/{headers/AndroidScheduler.h → AndroidScheduler.h} +0 -0
- package/android/src/main/cpp/{headers/JNIHelper.h → JNIHelper.h} +0 -0
- package/android/src/main/cpp/{headers/LayoutAnimations.h → LayoutAnimations.h} +0 -0
- package/android/src/main/cpp/NativeProxy.cpp +60 -28
- package/android/src/main/cpp/{headers/NativeProxy.h → NativeProxy.h} +29 -0
- package/android/src/main/cpp/OnLoad.cpp +1 -0
- package/android/src/main/cpp/{headers/TurboModule.h → TurboModule.h} +0 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +29 -5
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +3 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +166 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +19 -16
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +5 -1
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +1 -1
- package/ios/{REAModule.m → REAModule.mm} +12 -0
- package/ios/REANodesManager.m +31 -8
- package/ios/keyboardObserver/REAKeyboardEventObserver.h +17 -0
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +198 -0
- package/ios/native/NativeProxy.mm +24 -3
- package/ios/native/REAInitializer.h +2 -2
- package/ios/native/REAInitializer.mm +10 -14
- package/ios/native/UIResponder+Reanimated.mm +1 -1
- package/ios/sensor/ReanimatedSensor.m +26 -17
- package/lib/index.js +11 -3
- package/lib/index.web.js +6 -0
- package/lib/reanimated2/Colors.js +1 -1
- package/lib/reanimated2/NativeMethods.js +34 -17
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +6 -0
- package/lib/reanimated2/animation/util.js +4 -1
- package/lib/reanimated2/commonTypes.js +8 -1
- package/lib/reanimated2/component/FlatList.js +5 -5
- package/lib/reanimated2/core.js +5 -4
- package/lib/reanimated2/frameCallback/FrameCallbackRegistryJS.js +32 -0
- package/lib/reanimated2/frameCallback/FrameCallbackRegistryUI.js +76 -0
- package/lib/reanimated2/globals.d.ts +5 -2
- package/lib/reanimated2/hook/index.js +3 -0
- package/lib/reanimated2/hook/useAnimatedKeyboard.js +31 -0
- package/lib/reanimated2/hook/useAnimatedSensor.js +3 -3
- package/lib/reanimated2/hook/useFrameCallback.js +23 -0
- package/lib/reanimated2/hook/useScrollViewOffset.js +26 -0
- package/lib/reanimated2/jestUtils.js +11 -3
- package/lib/reanimated2/js-reanimated/JSReanimated.js +7 -0
- package/lib/reanimated2/js-reanimated/global.js +33 -22
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +1 -1
- package/lib/reanimated2/utils.js +10 -3
- package/lib/types/{lib/Animated.d.ts → Animated.d.ts} +0 -0
- package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
- package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
- package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/{lib/index.d.ts → index.web.d.ts} +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +3 -10
- package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +3 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +20 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +2 -2
- package/lib/types/{lib/reanimated2 → reanimated2}/component/Image.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/component/ScrollView.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/component/Text.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/component/View.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
- package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryJS.d.ts +8 -0
- package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +6 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +4 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
- package/lib/types/reanimated2/hook/useAnimatedKeyboard.d.ts +2 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +1 -2
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +1 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
- package/lib/types/reanimated2/hook/useFrameCallback.d.ts +7 -0
- package/lib/types/reanimated2/hook/useScrollViewOffset.d.ts +4 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +1 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +3 -1
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
- package/lib/types/reanimated2/js-reanimated/global.d.ts +2 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
- package/lib/types/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
- package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +5 -1
- package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
- package/mock.js +1 -0
- package/package.json +8 -8
- package/plugin.js +8 -17
- package/react-native-reanimated.d.ts +67 -12
- package/scripts/reanimated_utils.rb +65 -0
- package/src/index.ts +11 -3
- package/src/index.web.ts +7 -0
- package/src/reanimated2/Colors.ts +1 -1
- package/src/reanimated2/NativeMethods.ts +47 -30
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +9 -0
- package/src/reanimated2/animation/util.ts +8 -1
- package/src/reanimated2/commonTypes.ts +24 -0
- package/src/reanimated2/component/FlatList.tsx +29 -19
- package/src/reanimated2/core.ts +8 -8
- package/src/reanimated2/frameCallback/FrameCallbackRegistryJS.ts +40 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +115 -0
- package/src/reanimated2/globals.d.ts +5 -2
- package/src/reanimated2/hook/index.ts +4 -0
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +35 -0
- package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -1
- package/src/reanimated2/hook/useAnimatedSensor.ts +5 -5
- package/src/reanimated2/hook/useFrameCallback.ts +40 -0
- package/src/reanimated2/hook/useScrollViewOffset.ts +36 -0
- package/src/reanimated2/jestUtils.ts +11 -3
- package/src/reanimated2/js-reanimated/JSReanimated.ts +16 -1
- package/src/reanimated2/js-reanimated/global.ts +41 -29
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +1 -1
- package/src/reanimated2/utils.ts +12 -5
- package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +0 -8
- package/lib/reanimated2/__mocks__/NativeReanimated.native.js +0 -20
- package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +0 -13
- package/lib/types/lib/reanimated2/js-reanimated/global.d.ts +0 -1
- package/lib/types/react-native-reanimated-tests.d.ts +0 -1
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
SharedValue,
|
|
4
4
|
SensorValue3D,
|
|
5
5
|
SensorValueRotation,
|
|
6
|
+
AnimatedKeyboardInfo,
|
|
6
7
|
} from '../commonTypes';
|
|
7
8
|
import { Descriptor } from '../hook/commonTypes';
|
|
8
9
|
|
|
@@ -97,4 +98,12 @@ export class NativeReanimated {
|
|
|
97
98
|
configureProps(uiProps: string[], nativeProps: string[]): void {
|
|
98
99
|
this.InnerNativeModule.configureProps(uiProps, nativeProps);
|
|
99
100
|
}
|
|
101
|
+
|
|
102
|
+
subscribeForKeyboardEvents(keyboardEventData: AnimatedKeyboardInfo): number {
|
|
103
|
+
return this.InnerNativeModule.subscribeForKeyboardEvents(keyboardEventData);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
unsubscribeFromKeyboardEvents(listenerId: number): void {
|
|
107
|
+
this.InnerNativeModule.unsubscribeFromKeyboardEvents(listenerId);
|
|
108
|
+
}
|
|
100
109
|
}
|
|
@@ -87,7 +87,14 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
87
87
|
animation.startValue = strippedValue;
|
|
88
88
|
animation.toValue = strippedToValue;
|
|
89
89
|
if (previousAnimation && previousAnimation !== animation) {
|
|
90
|
-
|
|
90
|
+
const {
|
|
91
|
+
prefix: paPrefix,
|
|
92
|
+
suffix: paSuffix,
|
|
93
|
+
strippedValue: paStrippedValue,
|
|
94
|
+
} = recognizePrefixSuffix(previousAnimation.current as string | number);
|
|
95
|
+
previousAnimation.current = paStrippedValue;
|
|
96
|
+
previousAnimation.__prefix = paPrefix;
|
|
97
|
+
previousAnimation.__suffix = paSuffix;
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
baseOnStart(animation, strippedValue, timestamp, previousAnimation);
|
|
@@ -145,3 +145,27 @@ export type ValueRotation = {
|
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
export type SensorValueRotation = SharedValue<ValueRotation>;
|
|
148
|
+
|
|
149
|
+
export type ShadowNodeWrapper = object;
|
|
150
|
+
|
|
151
|
+
export enum KeyboardState {
|
|
152
|
+
UNKNOWN = 0,
|
|
153
|
+
OPENING = 1,
|
|
154
|
+
OPEN = 2,
|
|
155
|
+
CLOSING = 3,
|
|
156
|
+
CLOSED = 4,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type AnimatedKeyboardInfo = {
|
|
160
|
+
height: SharedValue<number>;
|
|
161
|
+
state: SharedValue<KeyboardState>;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export interface MeasuredDimensions {
|
|
165
|
+
x: number;
|
|
166
|
+
y: number;
|
|
167
|
+
width: number;
|
|
168
|
+
height: number;
|
|
169
|
+
pageX: number;
|
|
170
|
+
pageY: number;
|
|
171
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ForwardedRef, forwardRef } from 'react';
|
|
2
2
|
import { FlatList, FlatListProps, LayoutChangeEvent } from 'react-native';
|
|
3
3
|
import ReanimatedView from './View';
|
|
4
4
|
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
@@ -6,10 +6,14 @@ import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/c
|
|
|
6
6
|
|
|
7
7
|
const AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;
|
|
8
8
|
|
|
9
|
+
interface AnimatedFlatListProps {
|
|
10
|
+
onLayout: (event: LayoutChangeEvent) => void;
|
|
11
|
+
// implicit `children` prop has been removed in @types/react^18.0.0
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
|
|
10
|
-
const cellRenderer:
|
|
11
|
-
onLayout: (event: LayoutChangeEvent) => void;
|
|
12
|
-
}> = (props) => {
|
|
16
|
+
const cellRenderer = (props: AnimatedFlatListProps) => {
|
|
13
17
|
return (
|
|
14
18
|
<ReanimatedView layout={itemLayoutAnimation} onLayout={props.onLayout}>
|
|
15
19
|
{props.children}
|
|
@@ -20,23 +24,29 @@ const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
|
|
|
20
24
|
return cellRenderer;
|
|
21
25
|
};
|
|
22
26
|
|
|
23
|
-
export interface
|
|
27
|
+
export interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {
|
|
24
28
|
itemLayoutAnimation?: ILayoutAnimationBuilder;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
type ReanimatedFlatListFC<T = any> = React.FC<
|
|
28
|
-
|
|
29
|
-
const ReanimatedFlatlist: ReanimatedFlatListFC = (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
31
|
+
type ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatListProps<T>>;
|
|
32
|
+
|
|
33
|
+
const ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(
|
|
34
|
+
(props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {
|
|
35
|
+
const { itemLayoutAnimation, ...restProps } = props;
|
|
36
|
+
|
|
37
|
+
const cellRenderer = React.useMemo(
|
|
38
|
+
() => createCellRenderer(itemLayoutAnimation),
|
|
39
|
+
[]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<AnimatedFlatList
|
|
44
|
+
ref={ref}
|
|
45
|
+
{...restProps}
|
|
46
|
+
CellRendererComponent={cellRenderer}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
41
51
|
|
|
42
52
|
export default ReanimatedFlatlist;
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -41,14 +41,18 @@ const testWorklet: BasicWorkletFunction<void> = () => {
|
|
|
41
41
|
'worklet';
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
const throwUninitializedReanimatedException = () => {
|
|
45
|
+
throw new Error(
|
|
46
|
+
"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache"
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
44
50
|
export const checkPluginState: (throwError: boolean) => boolean = (
|
|
45
51
|
throwError = true
|
|
46
52
|
) => {
|
|
47
53
|
if (!testWorklet.__workletHash && !shouldBeUseWeb()) {
|
|
48
54
|
if (throwError) {
|
|
49
|
-
|
|
50
|
-
"Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?"
|
|
51
|
-
);
|
|
55
|
+
throwUninitializedReanimatedException();
|
|
52
56
|
}
|
|
53
57
|
return false;
|
|
54
58
|
}
|
|
@@ -62,11 +66,7 @@ export const isConfigured: (throwError?: boolean) => boolean = (
|
|
|
62
66
|
};
|
|
63
67
|
|
|
64
68
|
export const isConfiguredCheck: () => void = () => {
|
|
65
|
-
|
|
66
|
-
throw new Error(
|
|
67
|
-
'If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation'
|
|
68
|
-
);
|
|
69
|
-
}
|
|
69
|
+
checkPluginState(true);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
function pushFrame(frame: (timestamp: Timestamp) => void): void {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { runOnUI } from '../core';
|
|
2
|
+
import { FrameInfo, prepareUIRegistry } from './FrameCallbackRegistryUI';
|
|
3
|
+
|
|
4
|
+
export default class FrameCallbackRegistryJS {
|
|
5
|
+
private nextCallbackId = 0;
|
|
6
|
+
|
|
7
|
+
constructor() {
|
|
8
|
+
prepareUIRegistry();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
registerFrameCallback(callback: (frameInfo: FrameInfo) => void): number {
|
|
12
|
+
if (!callback) {
|
|
13
|
+
return -1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const callbackId = this.nextCallbackId;
|
|
17
|
+
this.nextCallbackId++;
|
|
18
|
+
|
|
19
|
+
runOnUI(() => {
|
|
20
|
+
'worklet';
|
|
21
|
+
global._frameCallbackRegistry.registerFrameCallback(callback, callbackId);
|
|
22
|
+
})();
|
|
23
|
+
|
|
24
|
+
return callbackId;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
unregisterFrameCallback(callbackId: number): void {
|
|
28
|
+
runOnUI(() => {
|
|
29
|
+
'worklet';
|
|
30
|
+
global._frameCallbackRegistry.unregisterFrameCallback(callbackId);
|
|
31
|
+
})();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
manageStateFrameCallback(callbackId: number, state: boolean): void {
|
|
35
|
+
runOnUI(() => {
|
|
36
|
+
'worklet';
|
|
37
|
+
global._frameCallbackRegistry.manageStateFrameCallback(callbackId, state);
|
|
38
|
+
})();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { runOnUI } from '../core';
|
|
2
|
+
|
|
3
|
+
type CallbackDetails = {
|
|
4
|
+
callback: (frameInfo: FrameInfo) => void;
|
|
5
|
+
startTime: number | null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type FrameInfo = {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
timeSincePreviousFrame: number | null;
|
|
11
|
+
timeSinceFirstFrame: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface FrameCallbackRegistryUI {
|
|
15
|
+
frameCallbackRegistry: Map<number, CallbackDetails>;
|
|
16
|
+
activeFrameCallbacks: Set<number>;
|
|
17
|
+
previousFrameTimestamp: number | null;
|
|
18
|
+
runCallbacks: () => void;
|
|
19
|
+
registerFrameCallback: (
|
|
20
|
+
callback: (frameInfo: FrameInfo) => void,
|
|
21
|
+
callbackId: number
|
|
22
|
+
) => void;
|
|
23
|
+
unregisterFrameCallback: (callbackId: number) => void;
|
|
24
|
+
manageStateFrameCallback: (callbackId: number, state: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const prepareUIRegistry = runOnUI(() => {
|
|
28
|
+
'worklet';
|
|
29
|
+
|
|
30
|
+
const frameCallbackRegistry: FrameCallbackRegistryUI = {
|
|
31
|
+
frameCallbackRegistry: new Map<number, CallbackDetails>(),
|
|
32
|
+
activeFrameCallbacks: new Set<number>(),
|
|
33
|
+
previousFrameTimestamp: null,
|
|
34
|
+
|
|
35
|
+
runCallbacks() {
|
|
36
|
+
const loop = (timestamp: number) => {
|
|
37
|
+
if (this.previousFrameTimestamp === null) {
|
|
38
|
+
this.previousFrameTimestamp = timestamp;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const delta = timestamp - this.previousFrameTimestamp;
|
|
42
|
+
|
|
43
|
+
this.activeFrameCallbacks.forEach((callbackId: number) => {
|
|
44
|
+
const callbackDetails = this.frameCallbackRegistry.get(callbackId)!;
|
|
45
|
+
|
|
46
|
+
const { startTime } = callbackDetails;
|
|
47
|
+
|
|
48
|
+
if (startTime === null) {
|
|
49
|
+
// First frame
|
|
50
|
+
callbackDetails.startTime = timestamp;
|
|
51
|
+
|
|
52
|
+
callbackDetails.callback({
|
|
53
|
+
timestamp,
|
|
54
|
+
timeSincePreviousFrame: null,
|
|
55
|
+
timeSinceFirstFrame: 0,
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
// Next frame
|
|
59
|
+
callbackDetails.callback({
|
|
60
|
+
timestamp,
|
|
61
|
+
timeSincePreviousFrame: delta,
|
|
62
|
+
timeSinceFirstFrame: timestamp - startTime,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (this.activeFrameCallbacks.size > 0) {
|
|
68
|
+
this.previousFrameTimestamp = timestamp;
|
|
69
|
+
requestAnimationFrame(loop);
|
|
70
|
+
} else {
|
|
71
|
+
this.previousFrameTimestamp = null;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// runCallback() should only be called after registering a callback,
|
|
76
|
+
// so if there is only one active callback, then it means that there were
|
|
77
|
+
// zero previously and the loop isn't running yet.
|
|
78
|
+
if (this.activeFrameCallbacks.size === 1) {
|
|
79
|
+
requestAnimationFrame(loop);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
registerFrameCallback(
|
|
84
|
+
callback: (frameInfo: FrameInfo) => void,
|
|
85
|
+
callbackId: number
|
|
86
|
+
) {
|
|
87
|
+
this.frameCallbackRegistry.set(callbackId, {
|
|
88
|
+
callback: callback,
|
|
89
|
+
startTime: null,
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
unregisterFrameCallback(callbackId: number) {
|
|
94
|
+
this.manageStateFrameCallback(callbackId, false);
|
|
95
|
+
this.frameCallbackRegistry.delete(callbackId);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
manageStateFrameCallback(callbackId: number, state: boolean) {
|
|
99
|
+
if (callbackId === -1) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (state) {
|
|
103
|
+
this.activeFrameCallbacks.add(callbackId);
|
|
104
|
+
this.runCallbacks();
|
|
105
|
+
} else {
|
|
106
|
+
const callback = this.frameCallbackRegistry.get(callbackId)!;
|
|
107
|
+
callback.startTime = null;
|
|
108
|
+
|
|
109
|
+
this.activeFrameCallbacks.delete(callbackId);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
global._frameCallbackRegistry = frameCallbackRegistry;
|
|
115
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnimatedStyle, StyleProps } from './commonTypes';
|
|
2
2
|
import { ReanimatedConsole } from './core';
|
|
3
|
+
import FrameCallbackRegistryUI from './frameCallback/FrameCallbackRegistryUI';
|
|
3
4
|
import { MeasuredDimensions } from './NativeMethods';
|
|
4
5
|
import { NativeReanimated } from './NativeReanimated/NativeReanimated';
|
|
5
6
|
declare global {
|
|
@@ -19,7 +20,7 @@ declare global {
|
|
|
19
20
|
name: string,
|
|
20
21
|
updates: StyleProps | AnimatedStyle
|
|
21
22
|
) => void;
|
|
22
|
-
const _measure: (viewTag: number) => MeasuredDimensions;
|
|
23
|
+
const _measure: (viewTag: number) => MeasuredDimensions | null;
|
|
23
24
|
const _scrollTo: (
|
|
24
25
|
viewTag: number,
|
|
25
26
|
x: number,
|
|
@@ -30,6 +31,7 @@ declare global {
|
|
|
30
31
|
const ReanimatedDataMock: {
|
|
31
32
|
now: () => number;
|
|
32
33
|
};
|
|
34
|
+
const _frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
33
35
|
namespace NodeJS {
|
|
34
36
|
interface Global {
|
|
35
37
|
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
@@ -38,7 +40,7 @@ declare global {
|
|
|
38
40
|
_WORKLET: boolean;
|
|
39
41
|
__reanimatedModuleProxy: NativeReanimated;
|
|
40
42
|
_frameTimestamp: number | null;
|
|
41
|
-
_measure: () => MeasuredDimensions;
|
|
43
|
+
_measure: () => MeasuredDimensions | null;
|
|
42
44
|
_scrollTo: () => void;
|
|
43
45
|
_chronoNow: () => number;
|
|
44
46
|
performance: { now: () => number };
|
|
@@ -55,6 +57,7 @@ declare global {
|
|
|
55
57
|
ReanimatedDataMock: {
|
|
56
58
|
now: () => number;
|
|
57
59
|
};
|
|
60
|
+
_frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
}
|
|
@@ -24,3 +24,7 @@ export {
|
|
|
24
24
|
} from './useAnimatedScrollHandler';
|
|
25
25
|
export { useDerivedValue, DerivedValue } from './useDerivedValue';
|
|
26
26
|
export { useAnimatedSensor, SensorType } from './useAnimatedSensor';
|
|
27
|
+
export { useFrameCallback } from './useFrameCallback';
|
|
28
|
+
export type { FrameCallback } from './useFrameCallback';
|
|
29
|
+
export { useAnimatedKeyboard } from './useAnimatedKeyboard';
|
|
30
|
+
export { useScrollViewOffset } from './useScrollViewOffset';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import NativeReanimated from '../NativeReanimated';
|
|
3
|
+
import { makeMutable } from '../core';
|
|
4
|
+
import { AnimatedKeyboardInfo, KeyboardState } from '../commonTypes';
|
|
5
|
+
|
|
6
|
+
export function useAnimatedKeyboard(): AnimatedKeyboardInfo {
|
|
7
|
+
const ref = useRef<AnimatedKeyboardInfo | null>(null);
|
|
8
|
+
const listenerId = useRef<number>(-1);
|
|
9
|
+
const isSubscribed = useRef<boolean>(false);
|
|
10
|
+
|
|
11
|
+
if (ref.current === null) {
|
|
12
|
+
const keyboardEventData: AnimatedKeyboardInfo = {
|
|
13
|
+
state: makeMutable(KeyboardState.UNKNOWN),
|
|
14
|
+
height: makeMutable(0),
|
|
15
|
+
};
|
|
16
|
+
listenerId.current =
|
|
17
|
+
NativeReanimated.subscribeForKeyboardEvents(keyboardEventData);
|
|
18
|
+
ref.current = keyboardEventData;
|
|
19
|
+
isSubscribed.current = true;
|
|
20
|
+
}
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isSubscribed.current === false && ref.current !== null) {
|
|
23
|
+
// subscribe again after Fast Refresh
|
|
24
|
+
listenerId.current = NativeReanimated.subscribeForKeyboardEvents(
|
|
25
|
+
ref.current
|
|
26
|
+
);
|
|
27
|
+
isSubscribed.current = true;
|
|
28
|
+
}
|
|
29
|
+
return () => {
|
|
30
|
+
NativeReanimated.unsubscribeFromKeyboardEvents(listenerId.current);
|
|
31
|
+
isSubscribed.current = false;
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
return ref.current;
|
|
35
|
+
}
|
|
@@ -10,7 +10,9 @@ export interface ScrollHandler<TContext extends Context>
|
|
|
10
10
|
(event: NativeScrollEvent, context?: TContext): void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
interface ScrollEvent
|
|
13
|
+
export interface ScrollEvent
|
|
14
|
+
extends NativeScrollEvent,
|
|
15
|
+
NativeEvent<ScrollEvent> {
|
|
14
16
|
eventName: string;
|
|
15
17
|
}
|
|
16
18
|
export interface ScrollHandlers<TContext extends Context> {
|
|
@@ -12,7 +12,7 @@ export enum SensorType {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export type SensorConfig = {
|
|
15
|
-
interval: number;
|
|
15
|
+
interval: number | 'auto';
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export type AnimatedSensor = {
|
|
@@ -26,7 +26,7 @@ export function useAnimatedSensor(
|
|
|
26
26
|
sensorType: SensorType,
|
|
27
27
|
userConfig?: SensorConfig
|
|
28
28
|
): AnimatedSensor {
|
|
29
|
-
const ref = useRef({
|
|
29
|
+
const ref = useRef<AnimatedSensor>({
|
|
30
30
|
sensor: null,
|
|
31
31
|
unregister: () => {
|
|
32
32
|
// NOOP
|
|
@@ -38,7 +38,7 @@ export function useAnimatedSensor(
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
if (ref.current.sensor === null) {
|
|
41
|
-
ref.current.config = { interval:
|
|
41
|
+
ref.current.config = { interval: 'auto', ...userConfig };
|
|
42
42
|
let sensorData;
|
|
43
43
|
if (sensorType === SensorType.ROTATION) {
|
|
44
44
|
sensorData = {
|
|
@@ -61,10 +61,10 @@ export function useAnimatedSensor(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
useEffect(() => {
|
|
64
|
-
ref.current.config = { interval:
|
|
64
|
+
ref.current.config = { interval: 'auto', ...userConfig };
|
|
65
65
|
const id = NativeReanimated.registerSensor(
|
|
66
66
|
sensorType,
|
|
67
|
-
ref.current.config.interval,
|
|
67
|
+
ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval,
|
|
68
68
|
ref.current.sensor as any
|
|
69
69
|
);
|
|
70
70
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import FrameCallbackRegistryJS from '../frameCallback/FrameCallbackRegistryJS';
|
|
3
|
+
import { FrameInfo } from '../frameCallback/FrameCallbackRegistryUI';
|
|
4
|
+
|
|
5
|
+
export type FrameCallback = {
|
|
6
|
+
setActive: (isActive: boolean) => void;
|
|
7
|
+
isActive: boolean;
|
|
8
|
+
callbackId: number;
|
|
9
|
+
};
|
|
10
|
+
const frameCallbackRegistry = new FrameCallbackRegistryJS();
|
|
11
|
+
|
|
12
|
+
export function useFrameCallback(
|
|
13
|
+
callback: (frameInfo: FrameInfo) => void,
|
|
14
|
+
autostart = true
|
|
15
|
+
): FrameCallback {
|
|
16
|
+
const ref = useRef<FrameCallback>({
|
|
17
|
+
setActive: (isActive: boolean) => {
|
|
18
|
+
frameCallbackRegistry.manageStateFrameCallback(
|
|
19
|
+
ref.current.callbackId,
|
|
20
|
+
isActive
|
|
21
|
+
);
|
|
22
|
+
ref.current.isActive = isActive;
|
|
23
|
+
},
|
|
24
|
+
isActive: autostart,
|
|
25
|
+
callbackId: -1,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
ref.current.callbackId =
|
|
30
|
+
frameCallbackRegistry.registerFrameCallback(callback);
|
|
31
|
+
ref.current.setActive(ref.current.isActive);
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
frameCallbackRegistry.unregisterFrameCallback(ref.current.callbackId);
|
|
35
|
+
ref.current.callbackId = -1;
|
|
36
|
+
};
|
|
37
|
+
}, [callback, autostart]);
|
|
38
|
+
|
|
39
|
+
return ref.current;
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RefObject, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { findNodeHandle } from 'react-native';
|
|
4
|
+
import type Animated from 'react-native-reanimated';
|
|
5
|
+
import { useEvent, useSharedValue } from '.';
|
|
6
|
+
import { SharedValue } from '../commonTypes';
|
|
7
|
+
import { ScrollEvent } from './useAnimatedScrollHandler';
|
|
8
|
+
|
|
9
|
+
const subscribeForEvents = [
|
|
10
|
+
'onScroll',
|
|
11
|
+
'onScrollBeginDrag',
|
|
12
|
+
'onScrollEndDrag',
|
|
13
|
+
'onMomentumScrollBegin',
|
|
14
|
+
'onMomentumScrollEnd',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export function useScrollViewOffset(
|
|
18
|
+
aref: RefObject<Animated.ScrollView>
|
|
19
|
+
): SharedValue<number> {
|
|
20
|
+
const offsetRef = useRef(useSharedValue(0));
|
|
21
|
+
|
|
22
|
+
const event = useEvent<ScrollEvent>((event: ScrollEvent) => {
|
|
23
|
+
'worklet';
|
|
24
|
+
offsetRef.current.value =
|
|
25
|
+
event.contentOffset.x === 0
|
|
26
|
+
? event.contentOffset.y
|
|
27
|
+
: event.contentOffset.x;
|
|
28
|
+
}, subscribeForEvents);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const viewTag = findNodeHandle(aref.current);
|
|
32
|
+
event.current?.registerForEvents(viewTag as number);
|
|
33
|
+
}, [aref.current]);
|
|
34
|
+
|
|
35
|
+
return offsetRef.current;
|
|
36
|
+
}
|
|
@@ -167,9 +167,9 @@ const tickTravel = () => {
|
|
|
167
167
|
jest.advanceTimersByTime(frameTime);
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
export const withReanimatedTimer = (
|
|
170
|
+
export const withReanimatedTimer = (animationTest) => {
|
|
171
171
|
beforeTest();
|
|
172
|
-
|
|
172
|
+
animationTest();
|
|
173
173
|
afterTest();
|
|
174
174
|
};
|
|
175
175
|
|
|
@@ -188,7 +188,15 @@ export const advanceAnimationByFrame = (count) => {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
export const setUpTests = (userConfig = {}) => {
|
|
191
|
-
|
|
191
|
+
let expect;
|
|
192
|
+
try {
|
|
193
|
+
expect = require('expect');
|
|
194
|
+
} catch (_) {
|
|
195
|
+
// for Jest in version 28+
|
|
196
|
+
const { expect: expectModule } = require('@jest/globals');
|
|
197
|
+
expect = expectModule;
|
|
198
|
+
}
|
|
199
|
+
|
|
192
200
|
require('setimmediate');
|
|
193
201
|
frameTime = Math.round(1000 / config.fps);
|
|
194
202
|
|
|
@@ -2,7 +2,11 @@ import MapperRegistry from './MapperRegistry';
|
|
|
2
2
|
import Mapper from './Mapper';
|
|
3
3
|
import MutableValue from './MutableValue';
|
|
4
4
|
import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Timestamp,
|
|
7
|
+
NestedObjectValues,
|
|
8
|
+
AnimatedKeyboardInfo,
|
|
9
|
+
} from '../commonTypes';
|
|
6
10
|
import { isJest } from '../PlatformChecker';
|
|
7
11
|
|
|
8
12
|
export default class JSReanimated extends NativeReanimated {
|
|
@@ -126,4 +130,15 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
126
130
|
throw Error('This method can be only use in Jest testing.');
|
|
127
131
|
}
|
|
128
132
|
}
|
|
133
|
+
|
|
134
|
+
subscribeForKeyboardEvents(_: AnimatedKeyboardInfo): number {
|
|
135
|
+
console.warn(
|
|
136
|
+
'[Reanimated] useAnimatedKeyboard is not available on web yet.'
|
|
137
|
+
);
|
|
138
|
+
return -1;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
unsubscribeFromKeyboardEvents(_: number): void {
|
|
142
|
+
// noop
|
|
143
|
+
}
|
|
129
144
|
}
|
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
// In order to keep bundle size down, we treat this file as a polyfill for Web.
|
|
2
2
|
|
|
3
3
|
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
|
-
|
|
5
|
-
if (shouldBeUseWeb()) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const initializeGlobalsForWeb = () => {
|
|
5
|
+
if (shouldBeUseWeb()) {
|
|
6
|
+
global._frameTimestamp = null;
|
|
7
|
+
global._setGlobalConsole = (_val) => {
|
|
8
|
+
// noop
|
|
9
|
+
};
|
|
10
|
+
global._measure = () => {
|
|
11
|
+
console.warn(
|
|
12
|
+
"[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
|
|
13
|
+
);
|
|
14
|
+
return {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0,
|
|
17
|
+
width: 0,
|
|
18
|
+
height: 0,
|
|
19
|
+
pageX: 0,
|
|
20
|
+
pageY: 0,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
global._scrollTo = () => {
|
|
24
|
+
console.warn(
|
|
25
|
+
"[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version"
|
|
26
|
+
);
|
|
21
27
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
global._setGestureState = () => {
|
|
29
|
+
console.warn(
|
|
30
|
+
"[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version"
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
If a file doesn't export anything, tree shaking doesn't pack
|
|
39
|
+
it into the JS bundle. In effect, the code inside of this file
|
|
40
|
+
will never execute. That is why we wrapped initialization code
|
|
41
|
+
into a function, and we call this one during creating
|
|
42
|
+
the module export object.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
export default initializeGlobalsForWeb();
|