react-native-reanimated 3.7.0 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +3 -9
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +20 -9
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +8 -8
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/package.json +1 -1
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +3 -19
- package/src/reanimated2/hook/useAnimatedSensor.ts +31 -12
- package/src/reanimated2/hook/useAnimatedStyle.ts +11 -5
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
|
@@ -35,12 +35,6 @@ if (IS_WEB) {
|
|
|
35
35
|
function onlyAnimatedStyles(styles) {
|
|
36
36
|
return styles.filter(style => style === null || style === void 0 ? void 0 : style.viewDescriptors);
|
|
37
37
|
}
|
|
38
|
-
function isSameAnimatedStyle(style1, style2) {
|
|
39
|
-
// We cannot use equality check to compare useAnimatedStyle outputs directly.
|
|
40
|
-
// Instead, we can compare its viewsRefs.
|
|
41
|
-
return (style1 === null || style1 === void 0 ? void 0 : style1.viewsRef) === (style2 === null || style2 === void 0 ? void 0 : style2.viewsRef);
|
|
42
|
-
}
|
|
43
|
-
const isSameAnimatedProps = isSameAnimatedStyle;
|
|
44
38
|
|
|
45
39
|
/**
|
|
46
40
|
* Lets you create an Animated version of any React Native component.
|
|
@@ -298,11 +292,11 @@ export function createAnimatedComponent(Component, options) {
|
|
|
298
292
|
// remove old styles
|
|
299
293
|
if (prevStyles) {
|
|
300
294
|
// in most of the cases, views have only a single animated style and it remains unchanged
|
|
301
|
-
const hasOneSameStyle = styles.length === 1 && prevStyles.length === 1 &&
|
|
295
|
+
const hasOneSameStyle = styles.length === 1 && prevStyles.length === 1 && styles[0] === prevStyles[0];
|
|
302
296
|
if (!hasOneSameStyle) {
|
|
303
297
|
// otherwise, remove each style that is not present in new styles
|
|
304
298
|
for (const prevStyle of prevStyles) {
|
|
305
|
-
const isPresent = styles.some(style =>
|
|
299
|
+
const isPresent = styles.some(style => style === prevStyle);
|
|
306
300
|
if (!isPresent) {
|
|
307
301
|
prevStyle.viewDescriptors.remove(viewTag);
|
|
308
302
|
}
|
|
@@ -331,7 +325,7 @@ export function createAnimatedComponent(Component, options) {
|
|
|
331
325
|
});
|
|
332
326
|
|
|
333
327
|
// detach old animatedProps
|
|
334
|
-
if (prevAnimatedProps &&
|
|
328
|
+
if (prevAnimatedProps && prevAnimatedProps !== this.props.animatedProps) {
|
|
335
329
|
prevAnimatedProps.viewDescriptors.remove(viewTag);
|
|
336
330
|
}
|
|
337
331
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","_defineProperty","obj","value","_toPropertyKey","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","TypeError","Number","React","findNodeHandle","Platform","WorkletEventHandler","invariant","adaptViewConfig","RNRenderer","enableLayoutAnimations","SharedTransition","LayoutAnimationType","getShadowNodeWrapperFromRef","removeFromPropsRegistry","getReduceMotionFromConfig","maybeBuild","SkipEnteringContext","JSPropsUpdater","has","flattenArray","setAndForwardRef","isFabric","isJest","isWeb","shouldBeUseWeb","InlinePropManager","PropsFilter","startWebLayoutAnimation","tryActivateLayoutTransition","configureWebLayoutAnimations","getReducedMotionFromConfig","saveSnapshot","updateLayoutAnimations","addHTMLMutationObserver","IS_WEB","IS_FABRIC","onlyAnimatedStyles","styles","filter","style","viewDescriptors","isSameAnimatedStyle","style1","style2","viewsRef","isSameAnimatedProps","createAnimatedComponent","Component","options","isReactComponent","name","AnimatedComponent","constructor","props","getForwardedRef","forwardedRef","setLocalRef","ref","tag","layout","entering","exiting","sharedTransitionTag","_this$context","skipEntering","context","current","_this$props","ENTERING","displayName","sharedElementTransition","sharedTransitionStyle","reduceMotionInTransition","getReduceMotion","registerTransition","_sharedElementTransition","_component","jestAnimatedStyle","componentDidMount","_attachNativeEvents","_jsPropsUpdater","addOnJSPropsChangeListener","_attachAnimatedStyles","_InlinePropManager","attachInlineProps","_getViewInfo","_configureLayoutTransition","_isFirstRender","componentWillUnmount","_this$_sharedElementT","_detachNativeEvents","removeOnJSPropsChangeListener","_detachStyles","detachInlineProps","unregisterTransition","_viewTag","EXITING","reduceMotionInExiting","_this$props2","_getEventViewRef","_this$_component","_getScrollableNode","_ref","getScrollableNode","node","viewTag","prop","setNativeProps","registerForEvents","unregisterFromEvents","_styles","remove","_this$props$animatedP","animatedProps","_reattachNativeEvents","prevProps","reattachNeeded","_updateFromNative","_this$_component2","_this$_component2$set","_this$_component3","_getAnimatableRef","_ref2","_viewInfo","viewName","shadowNodeWrapper","viewConfig","component","getAnimatableRef","_hostInstance$viewCon","hostInstance","findHostInstance_DEPRECATED","Error","_nativeTag","uiViewClassName","_this$props$animatedP2","_this$props$animatedP3","prevStyles","prevAnimatedProps","_animatedProps","hasReanimated2Props","hasOneSameStyle","prevStyle","isPresent","some","forEach","add","initial","componentDidUpdate","_prevState","snapshot","oldLayout","LAYOUT","getSnapshotBeforeUpdate","_this$_component4","getBoundingClientRect","render","filteredProps","_PropsFilter","filterNonAnimatedProps","visibility","platformProps","select","web","default","collapsable","createElement","_setComponentRef","forwardRef"],"sources":["createAnimatedComponent.tsx"],"sourcesContent":["'use strict';\nimport type {\n Component,\n ComponentClass,\n ComponentType,\n FunctionComponent,\n MutableRefObject,\n} from 'react';\nimport React from 'react';\nimport { findNodeHandle, Platform } from 'react-native';\nimport WorkletEventHandler from '../reanimated2/WorkletEventHandler';\nimport '../reanimated2/layoutReanimation/animationsManager';\nimport invariant from 'invariant';\nimport { adaptViewConfig } from '../ConfigHelper';\nimport { RNRenderer } from '../reanimated2/platform-specific/RNRenderer';\nimport { enableLayoutAnimations } from '../reanimated2/core';\nimport {\n SharedTransition,\n LayoutAnimationType,\n} from '../reanimated2/layoutReanimation';\nimport type { StyleProps, ShadowNodeWrapper } from '../reanimated2/commonTypes';\nimport { getShadowNodeWrapperFromRef } from '../reanimated2/fabricUtils';\nimport { removeFromPropsRegistry } from '../reanimated2/PropsRegistry';\nimport { getReduceMotionFromConfig } from '../reanimated2/animation/util';\nimport { maybeBuild } from '../animationBuilder';\nimport { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';\nimport type { AnimateProps } from '../reanimated2';\nimport JSPropsUpdater from './JSPropsUpdater';\nimport type {\n AnimatedComponentProps,\n AnimatedProps,\n InitialComponentProps,\n AnimatedComponentRef,\n IAnimatedComponentInternal,\n ViewInfo,\n} from './commonTypes';\nimport { has, flattenArray } from './utils';\nimport setAndForwardRef from './setAndForwardRef';\nimport {\n isFabric,\n isJest,\n isWeb,\n shouldBeUseWeb,\n} from '../reanimated2/PlatformChecker';\nimport { InlinePropManager } from './InlinePropManager';\nimport { PropsFilter } from './PropsFilter';\nimport {\n startWebLayoutAnimation,\n tryActivateLayoutTransition,\n configureWebLayoutAnimations,\n getReducedMotionFromConfig,\n saveSnapshot,\n} from '../reanimated2/layoutReanimation/web';\nimport { updateLayoutAnimations } from '../reanimated2/UpdateLayoutAnimations';\nimport type { CustomConfig } from '../reanimated2/layoutReanimation/web/config';\nimport type { FlatList, FlatListProps } from 'react-native';\nimport { addHTMLMutationObserver } from '../reanimated2/layoutReanimation/web/domUtils';\n\nconst IS_WEB = isWeb();\nconst IS_FABRIC = isFabric();\n\nif (IS_WEB) {\n configureWebLayoutAnimations();\n}\n\nfunction onlyAnimatedStyles(styles: StyleProps[]): StyleProps[] {\n return styles.filter((style) => style?.viewDescriptors);\n}\n\nfunction isSameAnimatedStyle(\n style1?: StyleProps,\n style2?: StyleProps\n): boolean {\n // We cannot use equality check to compare useAnimatedStyle outputs directly.\n // Instead, we can compare its viewsRefs.\n return style1?.viewsRef === style2?.viewsRef;\n}\n\nconst isSameAnimatedProps = isSameAnimatedStyle;\n\ntype Options<P> = {\n setNativeProps: (ref: AnimatedComponentRef, props: P) => void;\n};\n\n/**\n * Lets you create an Animated version of any React Native component.\n *\n * @param component - The component you want to make animatable.\n * @returns A component that Reanimated is capable of animating.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent\n */\n\n// Don't change the order of overloads, since such a change breaks current behavior\nexport function createAnimatedComponent<P extends object>(\n component: FunctionComponent<P>,\n options?: Options<P>\n): FunctionComponent<AnimateProps<P>>;\n\nexport function createAnimatedComponent<P extends object>(\n component: ComponentClass<P>,\n options?: Options<P>\n): ComponentClass<AnimateProps<P>>;\n\nexport function createAnimatedComponent<P extends object>(\n // Actually ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P> but we need this overload too\n // since some external components (like FastImage) are typed just as ComponentType\n component: ComponentType<P>,\n options?: Options<P>\n): FunctionComponent<AnimateProps<P>> | ComponentClass<AnimateProps<P>>;\n\n/**\n * @deprecated Please use `Animated.FlatList` component instead of calling `Animated.createAnimatedComponent(FlatList)` manually.\n */\n// @ts-ignore This is required to create this overload, since type of createAnimatedComponent is incorrect and doesn't include typeof FlatList\nexport function createAnimatedComponent(\n component: typeof FlatList<unknown>,\n options?: Options<any>\n): ComponentClass<AnimateProps<FlatListProps<unknown>>>;\n\nexport function createAnimatedComponent(\n Component: ComponentType<InitialComponentProps>,\n options?: Options<InitialComponentProps>\n): any {\n invariant(\n typeof Component !== 'function' ||\n (Component.prototype && Component.prototype.isReactComponent),\n `Looks like you're passing a function component \\`${Component.name}\\` to \\`createAnimatedComponent\\` function which supports only class components. Please wrap your function component with \\`React.forwardRef()\\` or use a class component instead.`\n );\n\n class AnimatedComponent\n extends React.Component<AnimatedComponentProps<InitialComponentProps>>\n implements IAnimatedComponentInternal\n {\n _styles: StyleProps[] | null = null;\n _animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;\n _viewTag = -1;\n _isFirstRender = true;\n jestAnimatedStyle: { value: StyleProps } = { value: {} };\n _component: AnimatedComponentRef | HTMLElement | null = null;\n _sharedElementTransition: SharedTransition | null = null;\n _jsPropsUpdater = new JSPropsUpdater();\n _InlinePropManager = new InlinePropManager();\n _PropsFilter = new PropsFilter();\n _viewInfo?: ViewInfo;\n static displayName: string;\n static contextType = SkipEnteringContext;\n context!: React.ContextType<typeof SkipEnteringContext>;\n\n constructor(props: AnimatedComponentProps<InitialComponentProps>) {\n super(props);\n if (isJest()) {\n this.jestAnimatedStyle = { value: {} };\n }\n }\n\n componentDidMount() {\n this._attachNativeEvents();\n this._jsPropsUpdater.addOnJSPropsChangeListener(this);\n this._attachAnimatedStyles();\n this._InlinePropManager.attachInlineProps(this, this._getViewInfo());\n\n const layout = this.props.layout;\n if (layout) {\n this._configureLayoutTransition();\n }\n\n if (IS_WEB) {\n if (this.props.exiting) {\n saveSnapshot(this._component as HTMLElement);\n }\n\n if (\n !this.props.entering ||\n getReducedMotionFromConfig(this.props.entering as CustomConfig)\n ) {\n this._isFirstRender = false;\n return;\n }\n\n startWebLayoutAnimation(\n this.props,\n this._component as HTMLElement,\n LayoutAnimationType.ENTERING\n );\n }\n\n this._isFirstRender = false;\n }\n\n componentWillUnmount() {\n this._detachNativeEvents();\n this._jsPropsUpdater.removeOnJSPropsChangeListener(this);\n this._detachStyles();\n this._InlinePropManager.detachInlineProps();\n this._sharedElementTransition?.unregisterTransition(this._viewTag);\n\n const exiting = this.props.exiting;\n if (\n IS_WEB &&\n this.props.exiting &&\n !getReducedMotionFromConfig(this.props.exiting as CustomConfig)\n ) {\n addHTMLMutationObserver();\n\n startWebLayoutAnimation(\n this.props,\n this._component as HTMLElement,\n LayoutAnimationType.EXITING\n );\n } else if (exiting) {\n const reduceMotionInExiting =\n 'getReduceMotion' in exiting &&\n typeof exiting.getReduceMotion === 'function'\n ? getReduceMotionFromConfig(exiting.getReduceMotion())\n : getReduceMotionFromConfig();\n if (!reduceMotionInExiting) {\n updateLayoutAnimations(\n this._viewTag,\n LayoutAnimationType.EXITING,\n maybeBuild(\n exiting,\n this.props?.style,\n AnimatedComponent.displayName\n )\n );\n }\n }\n }\n\n _getEventViewRef() {\n // Make sure to get the scrollable node for components that implement\n // `ScrollResponder.Mixin`.\n return (this._component as AnimatedComponentRef)?.getScrollableNode\n ? (this._component as AnimatedComponentRef).getScrollableNode?.()\n : this._component;\n }\n\n _attachNativeEvents() {\n const node = this._getEventViewRef() as AnimatedComponentRef;\n let viewTag = null; // We set it only if needed\n\n for (const key in this.props) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler\n ) {\n if (viewTag === null) {\n viewTag = findNodeHandle(options?.setNativeProps ? this : node);\n }\n prop.current.registerForEvents(viewTag as number, key);\n }\n }\n }\n\n _detachNativeEvents() {\n for (const key in this.props) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler\n ) {\n prop.current.unregisterFromEvents();\n }\n }\n }\n\n _detachStyles() {\n if (IS_WEB && this._styles !== null) {\n for (const style of this._styles) {\n style.viewsRef.remove(this);\n }\n } else if (this._viewTag !== -1 && this._styles !== null) {\n for (const style of this._styles) {\n style.viewDescriptors.remove(this._viewTag);\n }\n if (this.props.animatedProps?.viewDescriptors) {\n this.props.animatedProps.viewDescriptors.remove(this._viewTag);\n }\n if (IS_FABRIC) {\n removeFromPropsRegistry(this._viewTag);\n }\n }\n }\n\n _reattachNativeEvents(\n prevProps: AnimatedComponentProps<InitialComponentProps>\n ) {\n for (const key in prevProps) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler &&\n prop.current.reattachNeeded\n ) {\n prop.current.unregisterFromEvents();\n }\n }\n\n let viewTag = null;\n\n for (const key in this.props) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler &&\n prop.current.reattachNeeded\n ) {\n if (viewTag === null) {\n const node = this._getEventViewRef() as AnimatedComponentRef;\n viewTag = findNodeHandle(options?.setNativeProps ? this : node);\n }\n prop.current.registerForEvents(viewTag as number, key);\n prop.current.reattachNeeded = false;\n }\n }\n }\n\n _updateFromNative(props: StyleProps) {\n if (options?.setNativeProps) {\n options.setNativeProps(this._component as AnimatedComponentRef, props);\n } else {\n (this._component as AnimatedComponentRef)?.setNativeProps?.(props);\n }\n }\n\n _getViewInfo(): ViewInfo {\n if (this._viewInfo !== undefined) {\n return this._viewInfo;\n }\n\n let viewTag: number | HTMLElement | null;\n let viewName: string | null;\n let shadowNodeWrapper: ShadowNodeWrapper | null = null;\n let viewConfig;\n // Component can specify ref which should be animated when animated version of the component is created.\n // Otherwise, we animate the component itself.\n const component = (this._component as AnimatedComponentRef)\n ?.getAnimatableRef\n ? (this._component as AnimatedComponentRef).getAnimatableRef?.()\n : this;\n\n if (IS_WEB) {\n // At this point I assume that `_setComponentRef` was already called and `_component` is set.\n // `this._component` on web represents HTMLElement of our component, that's why we use casting\n viewTag = this._component as HTMLElement;\n viewName = null;\n shadowNodeWrapper = null;\n viewConfig = null;\n } else {\n // hostInstance can be null for a component that doesn't render anything (render function returns null). Example: svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx\n const hostInstance = RNRenderer.findHostInstance_DEPRECATED(component);\n if (!hostInstance) {\n throw new Error(\n '[Reanimated] Cannot find host instance for this component. Maybe it renders nothing?'\n );\n }\n // we can access view tag in the same way it's accessed here https://github.com/facebook/react/blob/e3f4eb7272d4ca0ee49f27577156b57eeb07cf73/packages/react-native-renderer/src/ReactFabric.js#L146\n viewTag = hostInstance?._nativeTag;\n /**\n * RN uses viewConfig for components for storing different properties of the component(example: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js#L24).\n * The name we're looking for is in the field named uiViewClassName.\n */\n viewName = hostInstance?.viewConfig?.uiViewClassName;\n\n viewConfig = hostInstance?.viewConfig;\n\n if (IS_FABRIC) {\n shadowNodeWrapper = getShadowNodeWrapperFromRef(this);\n }\n }\n this._viewInfo = { viewTag, viewName, shadowNodeWrapper, viewConfig };\n return this._viewInfo;\n }\n\n _attachAnimatedStyles() {\n const styles = this.props.style\n ? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))\n : [];\n const prevStyles = this._styles;\n this._styles = styles;\n\n const prevAnimatedProps = this._animatedProps;\n this._animatedProps = this.props.animatedProps;\n\n const { viewTag, viewName, shadowNodeWrapper, viewConfig } =\n this._getViewInfo();\n\n // update UI props whitelist for this view\n const hasReanimated2Props =\n this.props.animatedProps?.viewDescriptors || styles.length;\n if (hasReanimated2Props && viewConfig) {\n adaptViewConfig(viewConfig);\n }\n\n this._viewTag = viewTag as number;\n\n // remove old styles\n if (prevStyles) {\n // in most of the cases, views have only a single animated style and it remains unchanged\n const hasOneSameStyle =\n styles.length === 1 &&\n prevStyles.length === 1 &&\n isSameAnimatedStyle(styles[0], prevStyles[0]);\n\n if (!hasOneSameStyle) {\n // otherwise, remove each style that is not present in new styles\n for (const prevStyle of prevStyles) {\n const isPresent = styles.some((style) =>\n isSameAnimatedStyle(style, prevStyle)\n );\n if (!isPresent) {\n prevStyle.viewDescriptors.remove(viewTag);\n }\n }\n }\n }\n\n styles.forEach((style) => {\n style.viewDescriptors.add({\n tag: viewTag,\n name: viewName,\n shadowNodeWrapper,\n });\n if (isJest()) {\n /**\n * We need to connect Jest's TestObject instance whose contains just props object\n * with the updateProps() function where we update the properties of the component.\n * We can't update props object directly because TestObject contains a copy of props - look at render function:\n * const props = this._filterNonAnimatedProps(this.props);\n */\n this.jestAnimatedStyle.value = {\n ...this.jestAnimatedStyle.value,\n ...style.initial.value,\n };\n style.jestAnimatedStyle.current = this.jestAnimatedStyle;\n }\n });\n\n // detach old animatedProps\n if (\n prevAnimatedProps &&\n !isSameAnimatedProps(prevAnimatedProps, this.props.animatedProps)\n ) {\n prevAnimatedProps.viewDescriptors!.remove(viewTag as number);\n }\n\n // attach animatedProps property\n if (this.props.animatedProps?.viewDescriptors) {\n this.props.animatedProps.viewDescriptors.add({\n tag: viewTag as number,\n name: viewName!,\n shadowNodeWrapper: shadowNodeWrapper!,\n });\n }\n }\n\n componentDidUpdate(\n prevProps: AnimatedComponentProps<InitialComponentProps>,\n _prevState: Readonly<unknown>,\n // This type comes straight from React\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n snapshot: DOMRect | null\n ) {\n const layout = this.props.layout;\n const oldLayout = prevProps.layout;\n if (layout !== oldLayout) {\n this._configureLayoutTransition();\n }\n this._reattachNativeEvents(prevProps);\n this._attachAnimatedStyles();\n this._InlinePropManager.attachInlineProps(this, this._getViewInfo());\n\n if (IS_WEB && this.props.exiting) {\n saveSnapshot(this._component as HTMLElement);\n }\n\n // Snapshot won't be undefined because it comes from getSnapshotBeforeUpdate method\n if (\n IS_WEB &&\n snapshot !== null &&\n this.props.layout &&\n !getReducedMotionFromConfig(this.props.layout as CustomConfig)\n ) {\n tryActivateLayoutTransition(\n this.props,\n this._component as HTMLElement,\n snapshot\n );\n }\n }\n\n _configureLayoutTransition() {\n const layout = this.props.layout\n ? maybeBuild(\n this.props.layout,\n undefined /* We don't have to warn user if style has common properties with animation for LAYOUT */,\n AnimatedComponent.displayName\n )\n : undefined;\n updateLayoutAnimations(this._viewTag, LayoutAnimationType.LAYOUT, layout);\n }\n\n _setComponentRef = setAndForwardRef<Component | HTMLElement>({\n getForwardedRef: () =>\n this.props.forwardedRef as MutableRefObject<\n Component<Record<string, unknown>, Record<string, unknown>, unknown>\n >,\n setLocalRef: (ref) => {\n // TODO update config\n\n const tag = IS_WEB\n ? (ref as HTMLElement)\n : findNodeHandle(ref as Component);\n\n const { layout, entering, exiting, sharedTransitionTag } = this.props;\n if (\n (layout || entering || exiting || sharedTransitionTag) &&\n tag != null\n ) {\n if (!shouldBeUseWeb()) {\n enableLayoutAnimations(true, false);\n }\n\n const skipEntering = this.context?.current;\n if (entering && !skipEntering) {\n updateLayoutAnimations(\n tag as number,\n LayoutAnimationType.ENTERING,\n maybeBuild(\n entering,\n this.props?.style,\n AnimatedComponent.displayName\n )\n );\n }\n if (sharedTransitionTag && !IS_WEB) {\n const sharedElementTransition =\n this.props.sharedTransitionStyle ?? new SharedTransition();\n const reduceMotionInTransition = getReduceMotionFromConfig(\n sharedElementTransition.getReduceMotion()\n );\n if (!reduceMotionInTransition) {\n sharedElementTransition.registerTransition(\n tag as number,\n sharedTransitionTag\n );\n this._sharedElementTransition = sharedElementTransition;\n }\n }\n }\n\n if (ref !== this._component) {\n this._component = ref;\n }\n },\n });\n\n // This is a component lifecycle method from React, therefore we are not calling it directly.\n // It is called before the component gets rerendered. This way we can access components' position before it changed\n // and later on, in componentDidUpdate, calculate translation for layout transition.\n getSnapshotBeforeUpdate() {\n if (\n IS_WEB &&\n (this._component as HTMLElement)?.getBoundingClientRect !== undefined\n ) {\n return (this._component as HTMLElement).getBoundingClientRect();\n }\n\n return null;\n }\n\n render() {\n const filteredProps = this._PropsFilter.filterNonAnimatedProps(this);\n\n if (isJest()) {\n filteredProps.jestAnimatedStyle = this.jestAnimatedStyle;\n }\n\n // Layout animations on web are set inside `componentDidMount` method, which is called after first render.\n // Because of that we can encounter a situation in which component is visible for a short amount of time, and later on animation triggers.\n // I've tested that on various browsers and devices and it did not happen to me. To be sure that it won't happen to someone else,\n // I've decided to hide component at first render. Its visibility is reset in `componentDidMount`.\n if (\n this._isFirstRender &&\n IS_WEB &&\n filteredProps.entering &&\n !getReducedMotionFromConfig(filteredProps.entering as CustomConfig)\n ) {\n filteredProps.style = {\n ...(filteredProps.style ?? {}),\n visibility: 'hidden', // Hide component until `componentDidMount` triggers\n };\n }\n\n const platformProps = Platform.select({\n web: {},\n default: { collapsable: false },\n });\n\n return (\n <Component\n {...filteredProps}\n // Casting is used here, because ref can be null - in that case it cannot be assigned to HTMLElement.\n // After spending some time trying to figure out what to do with this problem, we decided to leave it this way\n ref={this._setComponentRef as (ref: Component) => void}\n {...platformProps}\n />\n );\n }\n }\n\n AnimatedComponent.displayName = `AnimatedComponent(${\n Component.displayName || Component.name || 'Component'\n })`;\n\n return React.forwardRef<Component>((props, ref) => {\n return (\n <AnimatedComponent\n {...props}\n {...(ref === null ? null : { forwardedRef: ref })}\n />\n );\n });\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,SAAA,IAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,GAAAF,SAAA,CAAAD,CAAA,YAAAI,GAAA,IAAAD,MAAA,QAAAP,MAAA,CAAAS,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAJ,MAAA,EAAAC,GAAA,KAAAL,MAAA,CAAAK,GAAA,IAAAD,MAAA,CAAAC,GAAA,gBAAAL,MAAA,YAAAJ,QAAA,CAAAa,KAAA,OAAAP,SAAA;AAAA,SAAAQ,gBAAAC,GAAA,EAAAN,GAAA,EAAAO,KAAA,IAAAP,GAAA,GAAAQ,cAAA,CAAAR,GAAA,OAAAA,GAAA,IAAAM,GAAA,IAAAd,MAAA,CAAAiB,cAAA,CAAAH,GAAA,EAAAN,GAAA,IAAAO,KAAA,EAAAA,KAAA,EAAAG,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAN,GAAA,CAAAN,GAAA,IAAAO,KAAA,WAAAD,GAAA;AAAA,SAAAE,eAAAK,GAAA,QAAAb,GAAA,GAAAc,YAAA,CAAAD,GAAA,2BAAAb,GAAA,gBAAAA,GAAA,GAAAe,MAAA,CAAAf,GAAA;AAAA,SAAAc,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,i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a,CAAChF,iBAAiB,GAAG,IAAI,CAACA,iBAAiB;MAC1D;;MAEA;MACA;MACA;MACA;MACA,IACE,IAAI,CAACU,cAAc,IACnBrD,MAAM,IACN2H,aAAa,CAACjG,QAAQ,IACtB,CAAC9B,0BAA0B,CAAC+H,aAAa,CAACjG,QAAQ,CAAiB,EACnE;QACAiG,aAAa,CAACtH,KAAK,GAAG;UACpB,IAAIsH,aAAa,CAACtH,KAAK,IAAI,CAAC,CAAC,CAAC;UAC9ByH,UAAU,EAAE,QAAQ,CAAE;QACxB,CAAC;MACH;;MAEA,MAAMC,aAAa,GAAG7J,QAAQ,CAAC8J,MAAM,CAAC;QACpCC,GAAG,EAAE,CAAC,CAAC;QACPC,OAAO,EAAE;UAAEC,WAAW,EAAE;QAAM;MAChC,CAAC,CAAC;MAEF,oBACEnK,KAAA,CAAAoK,aAAA,CAACvH,SAAS,EAAA/E,QAAA,KACJ6L,aAAa;QACjB;QACA;QACApG,GAAG,EAAE,IAAI,CAAC8G;MAA6C,GACnDN,aAAa,EACjB;IAEN;EACF;EAACnL,eAAA,CAjeKqE,iBAAiB;EAAArE,eAAA,CAAjBqE,iBAAiB,iBAgBAnC,mBAAmB;EAmd1CmC,iBAAiB,CAACkB,WAAW,GAAI,qBAC/BtB,SAAS,CAACsB,WAAW,IAAItB,SAAS,CAACG,IAAI,IAAI,WAC5C,GAAE;EAEH,oBAAOhD,KAAK,CAACsK,UAAU,CAAY,CAACnH,KAAK,EAAEI,GAAG,KAAK;IACjD,oBACEvD,KAAA,CAAAoK,aAAA,CAACnH,iBAAiB,EAAAnF,QAAA,KACZqF,KAAK,EACJI,GAAG,KAAK,IAAI,GAAG,IAAI,GAAG;MAAEF,YAAY,EAAEE;IAAI,CAAC,EAChD;EAEN,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","_defineProperty","obj","value","_toPropertyKey","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","TypeError","Number","React","findNodeHandle","Platform","WorkletEventHandler","invariant","adaptViewConfig","RNRenderer","enableLayoutAnimations","SharedTransition","LayoutAnimationType","getShadowNodeWrapperFromRef","removeFromPropsRegistry","getReduceMotionFromConfig","maybeBuild","SkipEnteringContext","JSPropsUpdater","has","flattenArray","setAndForwardRef","isFabric","isJest","isWeb","shouldBeUseWeb","InlinePropManager","PropsFilter","startWebLayoutAnimation","tryActivateLayoutTransition","configureWebLayoutAnimations","getReducedMotionFromConfig","saveSnapshot","updateLayoutAnimations","addHTMLMutationObserver","IS_WEB","IS_FABRIC","onlyAnimatedStyles","styles","filter","style","viewDescriptors","createAnimatedComponent","Component","options","isReactComponent","name","AnimatedComponent","constructor","props","getForwardedRef","forwardedRef","setLocalRef","ref","tag","layout","entering","exiting","sharedTransitionTag","_this$context","skipEntering","context","current","_this$props","ENTERING","displayName","sharedElementTransition","sharedTransitionStyle","reduceMotionInTransition","getReduceMotion","registerTransition","_sharedElementTransition","_component","jestAnimatedStyle","componentDidMount","_attachNativeEvents","_jsPropsUpdater","addOnJSPropsChangeListener","_attachAnimatedStyles","_InlinePropManager","attachInlineProps","_getViewInfo","_configureLayoutTransition","_isFirstRender","componentWillUnmount","_this$_sharedElementT","_detachNativeEvents","removeOnJSPropsChangeListener","_detachStyles","detachInlineProps","unregisterTransition","_viewTag","EXITING","reduceMotionInExiting","_this$props2","_getEventViewRef","_this$_component","_getScrollableNode","_ref","getScrollableNode","node","viewTag","prop","setNativeProps","registerForEvents","unregisterFromEvents","_styles","viewsRef","remove","_this$props$animatedP","animatedProps","_reattachNativeEvents","prevProps","reattachNeeded","_updateFromNative","_this$_component2","_this$_component2$set","_this$_component3","_getAnimatableRef","_ref2","_viewInfo","viewName","shadowNodeWrapper","viewConfig","component","getAnimatableRef","_hostInstance$viewCon","hostInstance","findHostInstance_DEPRECATED","Error","_nativeTag","uiViewClassName","_this$props$animatedP2","_this$props$animatedP3","prevStyles","prevAnimatedProps","_animatedProps","hasReanimated2Props","hasOneSameStyle","prevStyle","isPresent","some","forEach","add","initial","componentDidUpdate","_prevState","snapshot","oldLayout","LAYOUT","getSnapshotBeforeUpdate","_this$_component4","getBoundingClientRect","render","filteredProps","_PropsFilter","filterNonAnimatedProps","visibility","platformProps","select","web","default","collapsable","createElement","_setComponentRef","forwardRef"],"sources":["createAnimatedComponent.tsx"],"sourcesContent":["'use strict';\nimport type {\n Component,\n ComponentClass,\n ComponentType,\n FunctionComponent,\n MutableRefObject,\n} from 'react';\nimport React from 'react';\nimport { findNodeHandle, Platform } from 'react-native';\nimport WorkletEventHandler from '../reanimated2/WorkletEventHandler';\nimport '../reanimated2/layoutReanimation/animationsManager';\nimport invariant from 'invariant';\nimport { adaptViewConfig } from '../ConfigHelper';\nimport { RNRenderer } from '../reanimated2/platform-specific/RNRenderer';\nimport { enableLayoutAnimations } from '../reanimated2/core';\nimport {\n SharedTransition,\n LayoutAnimationType,\n} from '../reanimated2/layoutReanimation';\nimport type { StyleProps, ShadowNodeWrapper } from '../reanimated2/commonTypes';\nimport { getShadowNodeWrapperFromRef } from '../reanimated2/fabricUtils';\nimport { removeFromPropsRegistry } from '../reanimated2/PropsRegistry';\nimport { getReduceMotionFromConfig } from '../reanimated2/animation/util';\nimport { maybeBuild } from '../animationBuilder';\nimport { SkipEnteringContext } from '../reanimated2/component/LayoutAnimationConfig';\nimport type { AnimateProps } from '../reanimated2';\nimport JSPropsUpdater from './JSPropsUpdater';\nimport type {\n AnimatedComponentProps,\n AnimatedProps,\n InitialComponentProps,\n AnimatedComponentRef,\n IAnimatedComponentInternal,\n ViewInfo,\n} from './commonTypes';\nimport { has, flattenArray } from './utils';\nimport setAndForwardRef from './setAndForwardRef';\nimport {\n isFabric,\n isJest,\n isWeb,\n shouldBeUseWeb,\n} from '../reanimated2/PlatformChecker';\nimport { InlinePropManager } from './InlinePropManager';\nimport { PropsFilter } from './PropsFilter';\nimport {\n startWebLayoutAnimation,\n tryActivateLayoutTransition,\n configureWebLayoutAnimations,\n getReducedMotionFromConfig,\n saveSnapshot,\n} from '../reanimated2/layoutReanimation/web';\nimport { updateLayoutAnimations } from '../reanimated2/UpdateLayoutAnimations';\nimport type { CustomConfig } from '../reanimated2/layoutReanimation/web/config';\nimport type { FlatList, FlatListProps } from 'react-native';\nimport { addHTMLMutationObserver } from '../reanimated2/layoutReanimation/web/domUtils';\n\nconst IS_WEB = isWeb();\nconst IS_FABRIC = isFabric();\n\nif (IS_WEB) {\n configureWebLayoutAnimations();\n}\n\nfunction onlyAnimatedStyles(styles: StyleProps[]): StyleProps[] {\n return styles.filter((style) => style?.viewDescriptors);\n}\n\ntype Options<P> = {\n setNativeProps: (ref: AnimatedComponentRef, props: P) => void;\n};\n\n/**\n * Lets you create an Animated version of any React Native component.\n *\n * @param component - The component you want to make animatable.\n * @returns A component that Reanimated is capable of animating.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent\n */\n\n// Don't change the order of overloads, since such a change breaks current behavior\nexport function createAnimatedComponent<P extends object>(\n component: FunctionComponent<P>,\n options?: Options<P>\n): FunctionComponent<AnimateProps<P>>;\n\nexport function createAnimatedComponent<P extends object>(\n component: ComponentClass<P>,\n options?: Options<P>\n): ComponentClass<AnimateProps<P>>;\n\nexport function createAnimatedComponent<P extends object>(\n // Actually ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P> but we need this overload too\n // since some external components (like FastImage) are typed just as ComponentType\n component: ComponentType<P>,\n options?: Options<P>\n): FunctionComponent<AnimateProps<P>> | ComponentClass<AnimateProps<P>>;\n\n/**\n * @deprecated Please use `Animated.FlatList` component instead of calling `Animated.createAnimatedComponent(FlatList)` manually.\n */\n// @ts-ignore This is required to create this overload, since type of createAnimatedComponent is incorrect and doesn't include typeof FlatList\nexport function createAnimatedComponent(\n component: typeof FlatList<unknown>,\n options?: Options<any>\n): ComponentClass<AnimateProps<FlatListProps<unknown>>>;\n\nexport function createAnimatedComponent(\n Component: ComponentType<InitialComponentProps>,\n options?: Options<InitialComponentProps>\n): any {\n invariant(\n typeof Component !== 'function' ||\n (Component.prototype && Component.prototype.isReactComponent),\n `Looks like you're passing a function component \\`${Component.name}\\` to \\`createAnimatedComponent\\` function which supports only class components. Please wrap your function component with \\`React.forwardRef()\\` or use a class component instead.`\n );\n\n class AnimatedComponent\n extends React.Component<AnimatedComponentProps<InitialComponentProps>>\n implements IAnimatedComponentInternal\n {\n _styles: StyleProps[] | null = null;\n _animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;\n _viewTag = -1;\n _isFirstRender = true;\n jestAnimatedStyle: { value: StyleProps } = { value: {} };\n _component: AnimatedComponentRef | HTMLElement | null = null;\n _sharedElementTransition: SharedTransition | null = null;\n _jsPropsUpdater = new JSPropsUpdater();\n _InlinePropManager = new InlinePropManager();\n _PropsFilter = new PropsFilter();\n _viewInfo?: ViewInfo;\n static displayName: string;\n static contextType = SkipEnteringContext;\n context!: React.ContextType<typeof SkipEnteringContext>;\n\n constructor(props: AnimatedComponentProps<InitialComponentProps>) {\n super(props);\n if (isJest()) {\n this.jestAnimatedStyle = { value: {} };\n }\n }\n\n componentDidMount() {\n this._attachNativeEvents();\n this._jsPropsUpdater.addOnJSPropsChangeListener(this);\n this._attachAnimatedStyles();\n this._InlinePropManager.attachInlineProps(this, this._getViewInfo());\n\n const layout = this.props.layout;\n if (layout) {\n this._configureLayoutTransition();\n }\n\n if (IS_WEB) {\n if (this.props.exiting) {\n saveSnapshot(this._component as HTMLElement);\n }\n\n if (\n !this.props.entering ||\n getReducedMotionFromConfig(this.props.entering as CustomConfig)\n ) {\n this._isFirstRender = false;\n return;\n }\n\n startWebLayoutAnimation(\n this.props,\n this._component as HTMLElement,\n LayoutAnimationType.ENTERING\n );\n }\n\n this._isFirstRender = false;\n }\n\n componentWillUnmount() {\n this._detachNativeEvents();\n this._jsPropsUpdater.removeOnJSPropsChangeListener(this);\n this._detachStyles();\n this._InlinePropManager.detachInlineProps();\n this._sharedElementTransition?.unregisterTransition(this._viewTag);\n\n const exiting = this.props.exiting;\n if (\n IS_WEB &&\n this.props.exiting &&\n !getReducedMotionFromConfig(this.props.exiting as CustomConfig)\n ) {\n addHTMLMutationObserver();\n\n startWebLayoutAnimation(\n this.props,\n this._component as HTMLElement,\n LayoutAnimationType.EXITING\n );\n } else if (exiting) {\n const reduceMotionInExiting =\n 'getReduceMotion' in exiting &&\n typeof exiting.getReduceMotion === 'function'\n ? getReduceMotionFromConfig(exiting.getReduceMotion())\n : getReduceMotionFromConfig();\n if (!reduceMotionInExiting) {\n updateLayoutAnimations(\n this._viewTag,\n LayoutAnimationType.EXITING,\n maybeBuild(\n exiting,\n this.props?.style,\n AnimatedComponent.displayName\n )\n );\n }\n }\n }\n\n _getEventViewRef() {\n // Make sure to get the scrollable node for components that implement\n // `ScrollResponder.Mixin`.\n return (this._component as AnimatedComponentRef)?.getScrollableNode\n ? (this._component as AnimatedComponentRef).getScrollableNode?.()\n : this._component;\n }\n\n _attachNativeEvents() {\n const node = this._getEventViewRef() as AnimatedComponentRef;\n let viewTag = null; // We set it only if needed\n\n for (const key in this.props) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler\n ) {\n if (viewTag === null) {\n viewTag = findNodeHandle(options?.setNativeProps ? this : node);\n }\n prop.current.registerForEvents(viewTag as number, key);\n }\n }\n }\n\n _detachNativeEvents() {\n for (const key in this.props) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler\n ) {\n prop.current.unregisterFromEvents();\n }\n }\n }\n\n _detachStyles() {\n if (IS_WEB && this._styles !== null) {\n for (const style of this._styles) {\n style.viewsRef.remove(this);\n }\n } else if (this._viewTag !== -1 && this._styles !== null) {\n for (const style of this._styles) {\n style.viewDescriptors.remove(this._viewTag);\n }\n if (this.props.animatedProps?.viewDescriptors) {\n this.props.animatedProps.viewDescriptors.remove(this._viewTag);\n }\n if (IS_FABRIC) {\n removeFromPropsRegistry(this._viewTag);\n }\n }\n }\n\n _reattachNativeEvents(\n prevProps: AnimatedComponentProps<InitialComponentProps>\n ) {\n for (const key in prevProps) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler &&\n prop.current.reattachNeeded\n ) {\n prop.current.unregisterFromEvents();\n }\n }\n\n let viewTag = null;\n\n for (const key in this.props) {\n const prop = this.props[key];\n if (\n has('current', prop) &&\n prop.current instanceof WorkletEventHandler &&\n prop.current.reattachNeeded\n ) {\n if (viewTag === null) {\n const node = this._getEventViewRef() as AnimatedComponentRef;\n viewTag = findNodeHandle(options?.setNativeProps ? this : node);\n }\n prop.current.registerForEvents(viewTag as number, key);\n prop.current.reattachNeeded = false;\n }\n }\n }\n\n _updateFromNative(props: StyleProps) {\n if (options?.setNativeProps) {\n options.setNativeProps(this._component as AnimatedComponentRef, props);\n } else {\n (this._component as AnimatedComponentRef)?.setNativeProps?.(props);\n }\n }\n\n _getViewInfo(): ViewInfo {\n if (this._viewInfo !== undefined) {\n return this._viewInfo;\n }\n\n let viewTag: number | HTMLElement | null;\n let viewName: string | null;\n let shadowNodeWrapper: ShadowNodeWrapper | null = null;\n let viewConfig;\n // Component can specify ref which should be animated when animated version of the component is created.\n // Otherwise, we animate the component itself.\n const component = (this._component as AnimatedComponentRef)\n ?.getAnimatableRef\n ? (this._component as AnimatedComponentRef).getAnimatableRef?.()\n : this;\n\n if (IS_WEB) {\n // At this point I assume that `_setComponentRef` was already called and `_component` is set.\n // `this._component` on web represents HTMLElement of our component, that's why we use casting\n viewTag = this._component as HTMLElement;\n viewName = null;\n shadowNodeWrapper = null;\n viewConfig = null;\n } else {\n // hostInstance can be null for a component that doesn't render anything (render function returns null). Example: svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx\n const hostInstance = RNRenderer.findHostInstance_DEPRECATED(component);\n if (!hostInstance) {\n throw new Error(\n '[Reanimated] Cannot find host instance for this component. Maybe it renders nothing?'\n );\n }\n // we can access view tag in the same way it's accessed here https://github.com/facebook/react/blob/e3f4eb7272d4ca0ee49f27577156b57eeb07cf73/packages/react-native-renderer/src/ReactFabric.js#L146\n viewTag = hostInstance?._nativeTag;\n /**\n * RN uses viewConfig for components for storing different properties of the component(example: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js#L24).\n * The name we're looking for is in the field named uiViewClassName.\n */\n viewName = hostInstance?.viewConfig?.uiViewClassName;\n\n viewConfig = hostInstance?.viewConfig;\n\n if (IS_FABRIC) {\n shadowNodeWrapper = getShadowNodeWrapperFromRef(this);\n }\n }\n this._viewInfo = { viewTag, viewName, shadowNodeWrapper, viewConfig };\n return this._viewInfo;\n }\n\n _attachAnimatedStyles() {\n const styles = this.props.style\n ? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))\n : [];\n const prevStyles = this._styles;\n this._styles = styles;\n\n const prevAnimatedProps = this._animatedProps;\n this._animatedProps = this.props.animatedProps;\n\n const { viewTag, viewName, shadowNodeWrapper, viewConfig } =\n this._getViewInfo();\n\n // update UI props whitelist for this view\n const hasReanimated2Props =\n this.props.animatedProps?.viewDescriptors || styles.length;\n if (hasReanimated2Props && viewConfig) {\n adaptViewConfig(viewConfig);\n }\n\n this._viewTag = viewTag as number;\n\n // remove old styles\n if (prevStyles) {\n // in most of the cases, views have only a single animated style and it remains unchanged\n const hasOneSameStyle =\n styles.length === 1 &&\n prevStyles.length === 1 &&\n styles[0] === prevStyles[0];\n\n if (!hasOneSameStyle) {\n // otherwise, remove each style that is not present in new styles\n for (const prevStyle of prevStyles) {\n const isPresent = styles.some((style) => style === prevStyle);\n if (!isPresent) {\n prevStyle.viewDescriptors.remove(viewTag);\n }\n }\n }\n }\n\n styles.forEach((style) => {\n style.viewDescriptors.add({\n tag: viewTag,\n name: viewName,\n shadowNodeWrapper,\n });\n if (isJest()) {\n /**\n * We need to connect Jest's TestObject instance whose contains just props object\n * with the updateProps() function where we update the properties of the component.\n * We can't update props object directly because TestObject contains a copy of props - look at render function:\n * const props = this._filterNonAnimatedProps(this.props);\n */\n this.jestAnimatedStyle.value = {\n ...this.jestAnimatedStyle.value,\n ...style.initial.value,\n };\n style.jestAnimatedStyle.current = this.jestAnimatedStyle;\n }\n });\n\n // detach old animatedProps\n if (prevAnimatedProps && prevAnimatedProps !== this.props.animatedProps) {\n prevAnimatedProps.viewDescriptors!.remove(viewTag as number);\n }\n\n // attach animatedProps property\n if (this.props.animatedProps?.viewDescriptors) {\n this.props.animatedProps.viewDescriptors.add({\n tag: viewTag as number,\n name: viewName!,\n shadowNodeWrapper: shadowNodeWrapper!,\n });\n }\n }\n\n componentDidUpdate(\n prevProps: AnimatedComponentProps<InitialComponentProps>,\n _prevState: Readonly<unknown>,\n // This type comes straight from React\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n snapshot: DOMRect | null\n ) {\n const layout = this.props.layout;\n const oldLayout = prevProps.layout;\n if (layout !== oldLayout) {\n this._configureLayoutTransition();\n }\n this._reattachNativeEvents(prevProps);\n this._attachAnimatedStyles();\n this._InlinePropManager.attachInlineProps(this, this._getViewInfo());\n\n if (IS_WEB && this.props.exiting) {\n saveSnapshot(this._component as HTMLElement);\n }\n\n // Snapshot won't be undefined because it comes from getSnapshotBeforeUpdate method\n if (\n IS_WEB &&\n snapshot !== null &&\n this.props.layout &&\n !getReducedMotionFromConfig(this.props.layout as CustomConfig)\n ) {\n tryActivateLayoutTransition(\n this.props,\n this._component as HTMLElement,\n snapshot\n );\n }\n }\n\n _configureLayoutTransition() {\n const layout = this.props.layout\n ? maybeBuild(\n this.props.layout,\n undefined /* We don't have to warn user if style has common properties with animation for LAYOUT */,\n AnimatedComponent.displayName\n )\n : undefined;\n updateLayoutAnimations(this._viewTag, LayoutAnimationType.LAYOUT, layout);\n }\n\n _setComponentRef = setAndForwardRef<Component | HTMLElement>({\n getForwardedRef: () =>\n this.props.forwardedRef as MutableRefObject<\n Component<Record<string, unknown>, Record<string, unknown>, unknown>\n >,\n setLocalRef: (ref) => {\n // TODO update config\n\n const tag = IS_WEB\n ? (ref as HTMLElement)\n : findNodeHandle(ref as Component);\n\n const { layout, entering, exiting, sharedTransitionTag } = this.props;\n if (\n (layout || entering || exiting || sharedTransitionTag) &&\n tag != null\n ) {\n if (!shouldBeUseWeb()) {\n enableLayoutAnimations(true, false);\n }\n\n const skipEntering = this.context?.current;\n if (entering && !skipEntering) {\n updateLayoutAnimations(\n tag as number,\n LayoutAnimationType.ENTERING,\n maybeBuild(\n entering,\n this.props?.style,\n AnimatedComponent.displayName\n )\n );\n }\n if (sharedTransitionTag && !IS_WEB) {\n const sharedElementTransition =\n this.props.sharedTransitionStyle ?? new SharedTransition();\n const reduceMotionInTransition = getReduceMotionFromConfig(\n sharedElementTransition.getReduceMotion()\n );\n if (!reduceMotionInTransition) {\n sharedElementTransition.registerTransition(\n tag as number,\n sharedTransitionTag\n );\n this._sharedElementTransition = sharedElementTransition;\n }\n }\n }\n\n if (ref !== this._component) {\n this._component = ref;\n }\n },\n });\n\n // This is a component lifecycle method from React, therefore we are not calling it directly.\n // It is called before the component gets rerendered. This way we can access components' position before it changed\n // and later on, in componentDidUpdate, calculate translation for layout transition.\n getSnapshotBeforeUpdate() {\n if (\n IS_WEB &&\n (this._component as HTMLElement)?.getBoundingClientRect !== undefined\n ) {\n return (this._component as HTMLElement).getBoundingClientRect();\n }\n\n return null;\n }\n\n render() {\n const filteredProps = this._PropsFilter.filterNonAnimatedProps(this);\n\n if (isJest()) {\n filteredProps.jestAnimatedStyle = this.jestAnimatedStyle;\n }\n\n // Layout animations on web are set inside `componentDidMount` method, which is called after first render.\n // Because of that we can encounter a situation in which component is visible for a short amount of time, and later on animation triggers.\n // I've tested that on various browsers and devices and it did not happen to me. To be sure that it won't happen to someone else,\n // I've decided to hide component at first render. Its visibility is reset in `componentDidMount`.\n if (\n this._isFirstRender &&\n IS_WEB &&\n filteredProps.entering &&\n !getReducedMotionFromConfig(filteredProps.entering as CustomConfig)\n ) {\n filteredProps.style = {\n ...(filteredProps.style ?? {}),\n visibility: 'hidden', // Hide component until `componentDidMount` triggers\n };\n }\n\n const platformProps = Platform.select({\n web: {},\n default: { collapsable: false },\n });\n\n return (\n <Component\n {...filteredProps}\n // Casting is used here, because ref can be null - in that case it cannot be assigned to HTMLElement.\n // After spending some time trying to figure out what to do with this problem, we decided to leave it this way\n ref={this._setComponentRef as (ref: Component) => void}\n {...platformProps}\n />\n );\n }\n }\n\n AnimatedComponent.displayName = `AnimatedComponent(${\n Component.displayName || Component.name || 'Component'\n })`;\n\n return React.forwardRef<Component>((props, ref) => {\n return (\n <AnimatedComponent\n {...props}\n {...(ref === null ? null : { forwardedRef: ref })}\n />\n );\n });\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,SAAA,IAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,GAAAF,SAAA,CAAAD,CAAA,YAAAI,GAAA,IAAAD,MAAA,QAAAP,MAAA,CAAAS,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAJ,MAAA,EAAAC,GAAA,KAAAL,MAAA,CAAAK,GAAA,IAAAD,MAAA,CAAAC,GAAA,gBAAAL,MAAA,YAAAJ,QAAA,CAAAa,KAAA,OAAAP,SAAA;AAAA,SAAAQ,gBAAAC,GAAA,EAAAN,GAAA,EAAAO,KAAA,IAAAP,GAAA,GAAAQ,cAAA,CAAAR,GAAA,OAAAA,GAAA,IAAAM,GAAA,IAAAd,MAAA,CAAAiB,cAAA,CAAAH,GAAA,EAAAN,GAAA,IAAAO,KAAA,EAAAA,KAAA,EAAAG,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAN,GAAA,CAAAN,GAAA,IAAAO,KAAA,WAAAD,GAAA;AAAA,SAAAE,eAAAK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2H,aAAa,CAAClG,QAAQ,CAAiB,EACnE;QACAkG,aAAa,CAAClH,KAAK,GAAG;UACpB,IAAIkH,aAAa,CAAClH,KAAK,IAAI,CAAC,CAAC,CAAC;UAC9BqH,UAAU,EAAE,QAAQ,CAAE;QACxB,CAAC;MACH;;MAEA,MAAMC,aAAa,GAAGzJ,QAAQ,CAAC0J,MAAM,CAAC;QACpCC,GAAG,EAAE,CAAC,CAAC;QACPC,OAAO,EAAE;UAAEC,WAAW,EAAE;QAAM;MAChC,CAAC,CAAC;MAEF,oBACE/J,KAAA,CAAAgK,aAAA,CAACxH,SAAS,EAAA1E,QAAA,KACJyL,aAAa;QACjB;QACA;QACArG,GAAG,EAAE,IAAI,CAAC+G;MAA6C,GACnDN,aAAa,EACjB;IAEN;EACF;EAAC/K,eAAA,CA5dKgE,iBAAiB;EAAAhE,eAAA,CAAjBgE,iBAAiB,iBAgBA9B,mBAAmB;EA8c1C8B,iBAAiB,CAACkB,WAAW,GAAI,qBAC/BtB,SAAS,CAACsB,WAAW,IAAItB,SAAS,CAACG,IAAI,IAAI,WAC5C,GAAE;EAEH,oBAAO3C,KAAK,CAACkK,UAAU,CAAY,CAACpH,KAAK,EAAEI,GAAG,KAAK;IACjD,oBACElD,KAAA,CAAAgK,aAAA,CAACpH,iBAAiB,EAAA9E,QAAA,KACZgF,KAAK,EACJI,GAAG,KAAK,IAAI,GAAG,IAAI,GAAG;MAAEF,YAAY,EAAEE;IAAI,CAAC,EAChD;EAEN,CAAC,CAAC;AACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import { initializeSensor, registerSensor, unregisterSensor } from '../core';
|
|
5
5
|
import { SensorType, IOSReferenceFrame, InterfaceOrientation } from '../commonTypes';
|
|
6
6
|
import { callMicrotasks } from '../threads';
|
|
@@ -78,12 +78,20 @@ function adjustVectorToInterfaceOrientation(data) {
|
|
|
78
78
|
*/
|
|
79
79
|
|
|
80
80
|
export function useAnimatedSensor(sensorType, userConfig) {
|
|
81
|
-
|
|
81
|
+
var _userConfigRef$curren, _userConfigRef$curren2, _userConfigRef$curren3;
|
|
82
|
+
const userConfigRef = useRef(userConfig);
|
|
83
|
+
const hasConfigChanged = ((_userConfigRef$curren = userConfigRef.current) === null || _userConfigRef$curren === void 0 ? void 0 : _userConfigRef$curren.adjustToInterfaceOrientation) !== (userConfig === null || userConfig === void 0 ? void 0 : userConfig.adjustToInterfaceOrientation) || ((_userConfigRef$curren2 = userConfigRef.current) === null || _userConfigRef$curren2 === void 0 ? void 0 : _userConfigRef$curren2.interval) !== (userConfig === null || userConfig === void 0 ? void 0 : userConfig.interval) || ((_userConfigRef$curren3 = userConfigRef.current) === null || _userConfigRef$curren3 === void 0 ? void 0 : _userConfigRef$curren3.iosReferenceFrame) !== (userConfig === null || userConfig === void 0 ? void 0 : userConfig.iosReferenceFrame);
|
|
84
|
+
if (hasConfigChanged) {
|
|
85
|
+
userConfigRef.current = {
|
|
86
|
+
...userConfig
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const config = useMemo(() => ({
|
|
82
90
|
interval: 'auto',
|
|
83
91
|
adjustToInterfaceOrientation: true,
|
|
84
92
|
iosReferenceFrame: IOSReferenceFrame.Auto,
|
|
85
|
-
...
|
|
86
|
-
};
|
|
93
|
+
...userConfigRef.current
|
|
94
|
+
}), [userConfigRef.current]);
|
|
87
95
|
const ref = useRef({
|
|
88
96
|
sensor: initializeSensor(sensorType, config),
|
|
89
97
|
unregister: () => {
|
|
@@ -93,11 +101,14 @@ export function useAnimatedSensor(sensorType, userConfig) {
|
|
|
93
101
|
config
|
|
94
102
|
});
|
|
95
103
|
useEffect(() => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
ref.current = {
|
|
105
|
+
sensor: initializeSensor(sensorType, config),
|
|
106
|
+
unregister: () => {
|
|
107
|
+
// NOOP
|
|
108
|
+
},
|
|
109
|
+
isAvailable: false,
|
|
110
|
+
config
|
|
99
111
|
};
|
|
100
|
-
ref.current.sensor = initializeSensor(sensorType, newConfig);
|
|
101
112
|
const sensorData = ref.current.sensor;
|
|
102
113
|
const adjustToInterfaceOrientation = ref.current.config.adjustToInterfaceOrientation;
|
|
103
114
|
const id = registerSensor(sensorType, config, data => {
|
|
@@ -127,7 +138,7 @@ export function useAnimatedSensor(sensorType, userConfig) {
|
|
|
127
138
|
return () => {
|
|
128
139
|
ref.current.unregister();
|
|
129
140
|
};
|
|
130
|
-
}, [sensorType,
|
|
141
|
+
}, [sensorType, config]);
|
|
131
142
|
return ref.current;
|
|
132
143
|
}
|
|
133
144
|
//# sourceMappingURL=useAnimatedSensor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","initializeSensor","registerSensor","unregisterSensor","SensorType","IOSReferenceFrame","InterfaceOrientation","callMicrotasks","eulerToQuaternion","pitch","roll","yaw","c1","Math","cos","s1","sin","c2","s2","c3","s3","adjustRotationToInterfaceOrientation","data","interfaceOrientation","ROTATION_90","PI","ROTATION_270","ROTATION_180","q","qx","qy","qz","qw","adjustVectorToInterfaceOrientation","x","y","useAnimatedSensor","sensorType","userConfig","config","interval","adjustToInterfaceOrientation","iosReferenceFrame","Auto","ref","sensor","unregister","isAvailable","newConfig","current","sensorData","id","ROTATION","value"],"sources":["useAnimatedSensor.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef } from 'react';\nimport { initializeSensor, registerSensor, unregisterSensor } from '../core';\nimport type {\n SensorConfig,\n AnimatedSensor,\n Value3D,\n ValueRotation,\n} from '../commonTypes';\nimport {\n SensorType,\n IOSReferenceFrame,\n InterfaceOrientation,\n} from '../commonTypes';\nimport { callMicrotasks } from '../threads';\n\n// euler angles are in order ZXY, z = yaw, x = pitch, y = roll\n// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237\nfunction eulerToQuaternion(pitch: number, roll: number, yaw: number) {\n 'worklet';\n const c1 = Math.cos(pitch / 2);\n const s1 = Math.sin(pitch / 2);\n const c2 = Math.cos(roll / 2);\n const s2 = Math.sin(roll / 2);\n const c3 = Math.cos(yaw / 2);\n const s3 = Math.sin(yaw / 2);\n\n return [\n s1 * c2 * c3 - c1 * s2 * s3,\n c1 * s2 * c3 + s1 * c2 * s3,\n c1 * c2 * s3 + s1 * s2 * c3,\n c1 * c2 * c3 - s1 * s2 * s3,\n ];\n}\n\nfunction adjustRotationToInterfaceOrientation(data: ValueRotation) {\n 'worklet';\n const { interfaceOrientation, pitch, roll, yaw } = data;\n if (interfaceOrientation === InterfaceOrientation.ROTATION_90) {\n data.pitch = roll;\n data.roll = -pitch;\n data.yaw = yaw - Math.PI / 2;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_270) {\n data.pitch = -roll;\n data.roll = pitch;\n data.yaw = yaw + Math.PI / 2;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_180) {\n data.pitch *= -1;\n data.roll *= -1;\n data.yaw *= -1;\n }\n\n const q = eulerToQuaternion(data.pitch, data.roll, data.yaw);\n data.qx = q[0];\n data.qy = q[1];\n data.qz = q[2];\n data.qw = q[3];\n return data;\n}\n\nfunction adjustVectorToInterfaceOrientation(data: Value3D) {\n 'worklet';\n const { interfaceOrientation, x, y } = data;\n if (interfaceOrientation === InterfaceOrientation.ROTATION_90) {\n data.x = -y;\n data.y = x;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_270) {\n data.x = y;\n data.y = -x;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_180) {\n data.x *= -1;\n data.y *= -1;\n }\n return data;\n}\n\n/**\n * Lets you create animations based on data from the device's sensors.\n *\n * @param sensorType - Type of the sensor to use. Configured with {@link SensorType} enum.\n * @param config - The sensor configuration - {@link SensorConfig}.\n * @returns An object containing the sensor measurements [shared value](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#shared-value) and a function to unregister the sensor\n * @see https://docs.swmansion.com/react-native-reanimated/docs/device/useAnimatedSensor\n */\nexport function useAnimatedSensor(\n sensorType: SensorType.ROTATION,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor<ValueRotation>;\nexport function useAnimatedSensor(\n sensorType: Exclude<SensorType, SensorType.ROTATION>,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor<Value3D>;\nexport function useAnimatedSensor(\n sensorType: SensorType,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor<ValueRotation> | AnimatedSensor<Value3D> {\n const config: SensorConfig = {\n interval: 'auto',\n adjustToInterfaceOrientation: true,\n iosReferenceFrame: IOSReferenceFrame.Auto,\n ...userConfig,\n };\n const ref = useRef<AnimatedSensor<Value3D | ValueRotation>>({\n sensor: initializeSensor(sensorType, config),\n unregister: () => {\n // NOOP\n },\n isAvailable: false,\n config,\n });\n\n useEffect(() => {\n const newConfig = {\n ...config,\n ...userConfig,\n };\n ref.current.sensor = initializeSensor(sensorType, newConfig);\n\n const sensorData = ref.current.sensor;\n const adjustToInterfaceOrientation =\n ref.current.config.adjustToInterfaceOrientation;\n\n const id = registerSensor(sensorType, config, (data) => {\n 'worklet';\n if (adjustToInterfaceOrientation) {\n if (sensorType === SensorType.ROTATION) {\n data = adjustRotationToInterfaceOrientation(data as ValueRotation);\n } else {\n data = adjustVectorToInterfaceOrientation(data as Value3D);\n }\n }\n sensorData.value = data;\n callMicrotasks();\n });\n\n if (id !== -1) {\n // if sensor is available\n ref.current.unregister = () => unregisterSensor(id);\n ref.current.isAvailable = true;\n } else {\n // if sensor is unavailable\n ref.current.unregister = () => {\n // NOOP\n };\n ref.current.isAvailable = false;\n }\n\n return () => {\n ref.current.unregister();\n };\n }, [sensorType, userConfig]);\n\n return ref.current as AnimatedSensor<ValueRotation> | AnimatedSensor<Value3D>;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,gBA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C,IAAIJ,UAAU,KAAKjC,UAAU,CAACgD,QAAQ,EAAE;UACtC9B,IAAI,GAAGD,oCAAoC,CAACC,IAAI,CAAkB;QACpE,CAAC,MAAM;UACLA,IAAI,GAAGW,kCAAkC,CAACX,IAAI,CAAY;QAC5D;MACF;MACA4B,UAAU,CAACG,KAAK,GAAG/B,IAAI;MACvBf,cAAc,EAAE;IAClB,CAAC,CAAC;IAEF,IAAI4C,EAAE,KAAK,CAAC,CAAC,EAAE;MACb;MACAP,GAAG,CAACK,OAAO,CAACH,UAAU,GAAG,MAAM3C,gBAAgB,CAACgD,EAAE,CAAC;MACnDP,GAAG,CAACK,OAAO,CAACF,WAAW,GAAG,IAAI;IAChC,CAAC,MAAM;MACL;MACAH,GAAG,CAACK,OAAO,CAACH,UAAU,GAAG,MAAM;QAC7B;MAAA,CACD;MACDF,GAAG,CAACK,OAAO,CAACF,WAAW,GAAG,KAAK;IACjC;IAEA,OAAO,MAAM;MACXH,GAAG,CAACK,OAAO,CAACH,UAAU,EAAE;IAC1B,CAAC;EACH,CAAC,EAAE,CAACT,UAAU,EAAEC,UAAU,CAAC,CAAC;EAE5B,OAAOM,GAAG,CAACK,OAAO;AACpB"}
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useRef","initializeSensor","registerSensor","unregisterSensor","SensorType","IOSReferenceFrame","InterfaceOrientation","callMicrotasks","eulerToQuaternion","pitch","roll","yaw","c1","Math","cos","s1","sin","c2","s2","c3","s3","adjustRotationToInterfaceOrientation","data","interfaceOrientation","ROTATION_90","PI","ROTATION_270","ROTATION_180","q","qx","qy","qz","qw","adjustVectorToInterfaceOrientation","x","y","useAnimatedSensor","sensorType","userConfig","_userConfigRef$curren","_userConfigRef$curren2","_userConfigRef$curren3","userConfigRef","hasConfigChanged","current","adjustToInterfaceOrientation","interval","iosReferenceFrame","config","Auto","ref","sensor","unregister","isAvailable","sensorData","id","ROTATION","value"],"sources":["useAnimatedSensor.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useMemo, useRef } from 'react';\nimport { initializeSensor, registerSensor, unregisterSensor } from '../core';\nimport type {\n SensorConfig,\n AnimatedSensor,\n Value3D,\n ValueRotation,\n} from '../commonTypes';\nimport {\n SensorType,\n IOSReferenceFrame,\n InterfaceOrientation,\n} from '../commonTypes';\nimport { callMicrotasks } from '../threads';\n\n// euler angles are in order ZXY, z = yaw, x = pitch, y = roll\n// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237\nfunction eulerToQuaternion(pitch: number, roll: number, yaw: number) {\n 'worklet';\n const c1 = Math.cos(pitch / 2);\n const s1 = Math.sin(pitch / 2);\n const c2 = Math.cos(roll / 2);\n const s2 = Math.sin(roll / 2);\n const c3 = Math.cos(yaw / 2);\n const s3 = Math.sin(yaw / 2);\n\n return [\n s1 * c2 * c3 - c1 * s2 * s3,\n c1 * s2 * c3 + s1 * c2 * s3,\n c1 * c2 * s3 + s1 * s2 * c3,\n c1 * c2 * c3 - s1 * s2 * s3,\n ];\n}\n\nfunction adjustRotationToInterfaceOrientation(data: ValueRotation) {\n 'worklet';\n const { interfaceOrientation, pitch, roll, yaw } = data;\n if (interfaceOrientation === InterfaceOrientation.ROTATION_90) {\n data.pitch = roll;\n data.roll = -pitch;\n data.yaw = yaw - Math.PI / 2;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_270) {\n data.pitch = -roll;\n data.roll = pitch;\n data.yaw = yaw + Math.PI / 2;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_180) {\n data.pitch *= -1;\n data.roll *= -1;\n data.yaw *= -1;\n }\n\n const q = eulerToQuaternion(data.pitch, data.roll, data.yaw);\n data.qx = q[0];\n data.qy = q[1];\n data.qz = q[2];\n data.qw = q[3];\n return data;\n}\n\nfunction adjustVectorToInterfaceOrientation(data: Value3D) {\n 'worklet';\n const { interfaceOrientation, x, y } = data;\n if (interfaceOrientation === InterfaceOrientation.ROTATION_90) {\n data.x = -y;\n data.y = x;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_270) {\n data.x = y;\n data.y = -x;\n } else if (interfaceOrientation === InterfaceOrientation.ROTATION_180) {\n data.x *= -1;\n data.y *= -1;\n }\n return data;\n}\n\n/**\n * Lets you create animations based on data from the device's sensors.\n *\n * @param sensorType - Type of the sensor to use. Configured with {@link SensorType} enum.\n * @param config - The sensor configuration - {@link SensorConfig}.\n * @returns An object containing the sensor measurements [shared value](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#shared-value) and a function to unregister the sensor\n * @see https://docs.swmansion.com/react-native-reanimated/docs/device/useAnimatedSensor\n */\nexport function useAnimatedSensor(\n sensorType: SensorType.ROTATION,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor<ValueRotation>;\nexport function useAnimatedSensor(\n sensorType: Exclude<SensorType, SensorType.ROTATION>,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor<Value3D>;\nexport function useAnimatedSensor(\n sensorType: SensorType,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor<ValueRotation> | AnimatedSensor<Value3D> {\n const userConfigRef = useRef(userConfig);\n\n const hasConfigChanged =\n userConfigRef.current?.adjustToInterfaceOrientation !==\n userConfig?.adjustToInterfaceOrientation ||\n userConfigRef.current?.interval !== userConfig?.interval ||\n userConfigRef.current?.iosReferenceFrame !== userConfig?.iosReferenceFrame;\n\n if (hasConfigChanged) {\n userConfigRef.current = { ...userConfig };\n }\n\n const config: SensorConfig = useMemo(\n () => ({\n interval: 'auto',\n adjustToInterfaceOrientation: true,\n iosReferenceFrame: IOSReferenceFrame.Auto,\n ...userConfigRef.current,\n }),\n [userConfigRef.current]\n );\n\n const ref = useRef<AnimatedSensor<Value3D | ValueRotation>>({\n sensor: initializeSensor(sensorType, config),\n unregister: () => {\n // NOOP\n },\n isAvailable: false,\n config,\n });\n\n useEffect(() => {\n ref.current = {\n sensor: initializeSensor(sensorType, config),\n unregister: () => {\n // NOOP\n },\n isAvailable: false,\n config,\n };\n\n const sensorData = ref.current.sensor;\n const adjustToInterfaceOrientation =\n ref.current.config.adjustToInterfaceOrientation;\n\n const id = registerSensor(sensorType, config, (data) => {\n 'worklet';\n if (adjustToInterfaceOrientation) {\n if (sensorType === SensorType.ROTATION) {\n data = adjustRotationToInterfaceOrientation(data as ValueRotation);\n } else {\n data = adjustVectorToInterfaceOrientation(data as Value3D);\n }\n }\n sensorData.value = data;\n callMicrotasks();\n });\n\n if (id !== -1) {\n // if sensor is available\n ref.current.unregister = () => unregisterSensor(id);\n ref.current.isAvailable = true;\n } else {\n // if sensor is unavailable\n ref.current.unregister = () => {\n // NOOP\n };\n ref.current.isAvailable = false;\n }\n\n return () => {\n ref.current.unregister();\n };\n }, [sensorType, config]);\n\n return ref.current as AnimatedSensor<ValueRotation> | AnimatedSensor<Value3D>;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,SAAS;AAO5E,SACEC,UAAU,EACVC,iBAAiB,EACjBC,oBAAoB,QACf,gBAAgB;AACvB,SAASC,cAAc,QAAQ,YAAY;;AAE3C;AACA;AACA,SAASC,iBAAiBA,CAACC,KAAa,EAAEC,IAAY,EAAEC,GAAW,EAAE;EACnE,SAAS;;EACT,MAAMC,EAAE,GAAGC,IAAI,CAACC,GAAG,CAACL,KAAK,GAAG,CAAC,CAAC;EAC9B,MAAMM,EAAE,GAAGF,IAAI,CAACG,GAAG,CAACP,KAAK,GAAG,CAAC,CAAC;EAC9B,MAAMQ,EAAE,GAAGJ,IAAI,CAACC,GAAG,CAACJ,IAAI,GAAG,CAAC,CAAC;EAC7B,MAAMQ,EAAE,GAAGL,IAAI,CAACG,GAAG,CAACN,IAAI,GAAG,CAAC,CAAC;EAC7B,MAAMS,EAAE,GAAGN,IAAI,CAACC,GAAG,CAACH,GAAG,GAAG,CAAC,CAAC;EAC5B,MAAMS,EAAE,GAAGP,IAAI,CAACG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EjD,MAAMU,EAAE,GAAGrD,cAAc,CAACmC,UAAU,EAAEW,MAAM,EAAG1B,IAAI,IAAK;MACtD,SAAS;;MACT,IAAIuB,4BAA4B,EAAE;QAChC,IAAIR,UAAU,KAAKjC,UAAU,CAACoD,QAAQ,EAAE;UACtClC,IAAI,GAAGD,oCAAoC,CAACC,IAAI,CAAkB;QACpE,CAAC,MAAM;UACLA,IAAI,GAAGW,kCAAkC,CAACX,IAAI,CAAY;QAC5D;MACF;MACAgC,UAAU,CAACG,KAAK,GAAGnC,IAAI;MACvBf,cAAc,EAAE;IAClB,CAAC,CAAC;IAEF,IAAIgD,EAAE,KAAK,CAAC,CAAC,EAAE;MACb;MACAL,GAAG,CAACN,OAAO,CAACQ,UAAU,GAAG,MAAMjD,gBAAgB,CAACoD,EAAE,CAAC;MACnDL,GAAG,CAACN,OAAO,CAACS,WAAW,GAAG,IAAI;IAChC,CAAC,MAAM;MACL;MACAH,GAAG,CAACN,OAAO,CAACQ,UAAU,GAAG,MAAM;QAC7B;MAAA,CACD;MACDF,GAAG,CAACN,OAAO,CAACS,WAAW,GAAG,KAAK;IACjC;IAEA,OAAO,MAAM;MACXH,GAAG,CAACN,OAAO,CAACQ,UAAU,EAAE;IAC1B,CAAC;EACH,CAAC,EAAE,CAACf,UAAU,EAAEW,MAAM,CAAC,CAAC;EAExB,OAAOE,GAAG,CAACN,OAAO;AACpB"}
|
|
@@ -22,7 +22,7 @@ function prepareAnimation(frameTimestamp, animatedProp, lastAnimation, lastValue
|
|
|
22
22
|
if (typeof animatedProp === 'object' && animatedProp.onFrame) {
|
|
23
23
|
const animation = animatedProp;
|
|
24
24
|
let value = animation.current;
|
|
25
|
-
if (lastValue !== undefined) {
|
|
25
|
+
if (lastValue !== undefined && lastValue !== null) {
|
|
26
26
|
if (typeof lastValue === 'object') {
|
|
27
27
|
if (lastValue.value !== undefined) {
|
|
28
28
|
// previously it was a shared value
|
|
@@ -369,19 +369,19 @@ For more, see the docs: \`https://docs.swmansion.com/react-native-reanimated/doc
|
|
|
369
369
|
};
|
|
370
370
|
}, [areAnimationsActive]);
|
|
371
371
|
checkSharedValueUsage(initial.value);
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
const animatedStyleHandle = useRef(null);
|
|
373
|
+
if (!animatedStyleHandle.current) {
|
|
374
|
+
animatedStyleHandle.current = isJest() ? {
|
|
374
375
|
viewDescriptors,
|
|
375
376
|
initial,
|
|
376
377
|
viewsRef,
|
|
377
378
|
jestAnimatedStyle
|
|
378
|
-
}
|
|
379
|
-
} else {
|
|
380
|
-
return {
|
|
381
|
-
viewDescriptors,
|
|
379
|
+
} : {
|
|
382
380
|
initial,
|
|
383
|
-
viewsRef
|
|
381
|
+
viewsRef,
|
|
382
|
+
viewDescriptors
|
|
384
383
|
};
|
|
385
384
|
}
|
|
385
|
+
return animatedStyleHandle.current;
|
|
386
386
|
}
|
|
387
387
|
//# sourceMappingURL=useAnimatedStyle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","makeShareable","startMapper","stopMapper","updateProps","updatePropsJestWrapper","initialUpdaterRun","useSharedValue","buildWorkletsHash","isAnimated","shallowEqual","validateAnimatedStyles","makeViewDescriptorsSet","useViewRefSet","isJest","shouldBeUseWeb","SHOULD_BE_USE_WEB","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","isAnimatedProps","arguments","length","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","global","__frameTimestamp","_getAnimationTimestamp","frame","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","jestStyleUpdater","animatedStyle","adapters","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","animatedUpdaterData","inputs","values","__closure","_dependencies","__DEV__","__workletHash","adaptersArray","adaptersHash","areAnimationsActive","jestAnimatedStyle","push","initialStyle","initial","remoteState","shareableViewDescriptors","fun","updaterFn","adapter","mapperId"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["'use strict';\nimport type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\nimport { makeShareable, startMapper, stopMapper } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport type {\n AnimatedStyleHandle,\n DefaultStyle,\n DependencyList,\n Descriptor,\n JestAnimatedStyleHandle,\n} from './commonTypes';\nimport type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';\nimport { makeViewDescriptorsSet, useViewRefSet } from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport type {\n AnimationObject,\n Timestamp,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n __AdapterWorkletFunction,\n __BasicWorkletFunction,\n WorkletFunction,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\ninterface AnimatedState {\n last: AnimatedStyle<any>;\n animations: AnimatedStyle<any>;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimatedUpdaterData {\n initial: {\n value: AnimatedStyle<any>;\n updater: () => AnimatedStyle<any>;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle<any>,\n lastAnimation: AnimatedStyle<any>,\n lastValue: AnimatedStyle<any>\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle<any>,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle<any>,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n isAnimatedProps = false\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef, isAnimatedProps);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle<any>>,\n adapters: __AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle<any> = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (\n typeof prop === 'object' &&\n prop !== null &&\n prop.value === undefined\n ) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop !== null &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `[Reanimated] Invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\n/**\n * Lets you create a styles object, similar to StyleSheet styles, which can be animated using shared values.\n *\n * @param updater - A function returning an object with style properties you want to animate.\n * @param dependencies - An optional array of dependencies. Only relevant when using Reanimated without the Babel plugin on the Web.\n * @returns An animated style object which has to be passed to the `style` property of an Animated component you want to animate.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedStyle\n */\n// You cannot pass Shared Values to `useAnimatedStyle` directly.\n// @ts-expect-error This overload is required by our API.\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: () => Style,\n dependencies?: DependencyList | null\n): Style;\n\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: WorkletFunction<[], Style>,\n dependencies?: DependencyList | null,\n adapters?: WorkletFunction | WorkletFunction[],\n isAnimatedProps = false\n): AnimatedStyleHandle<Style> | JestAnimatedStyleHandle<Style> {\n const viewsRef: ViewRefSet<unknown> | undefined = useViewRefSet();\n const animatedUpdaterData = useRef<AnimatedUpdaterData>();\n let inputs = Object.values(updater.__closure ?? {});\n if (SHOULD_BE_USE_WEB) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `[Reanimated] \\`useAnimatedStyle\\` was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel plugin.\nFor more, see the docs: \\`https://docs.swmansion.com/react-native-reanimated/docs/guides/web-support#web-without-the-babel-plugin\\`.`\n );\n }\n }\n const adaptersArray = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const areAnimationsActive = useSharedValue<boolean>(true);\n const jestAnimatedStyle = useRef<Style>({} as Style);\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!animatedUpdaterData.current) {\n const initialStyle = initialUpdaterRun(updater);\n if (__DEV__) {\n validateAnimatedStyles(initialStyle);\n }\n animatedUpdaterData.current = {\n initial: {\n value: initialStyle,\n updater,\n },\n remoteState: makeShareable({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n const { initial, remoteState, viewDescriptors } = animatedUpdaterData.current;\n const shareableViewDescriptors = viewDescriptors.shareableViewDescriptors;\n\n dependencies.push(shareableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater;\n if (adapters) {\n updaterFn = (() => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n }) as WorkletFunction<[], Style>;\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n shareableViewDescriptors,\n updater,\n remoteState,\n viewsRef,\n areAnimationsActive,\n jestAnimatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n shareableViewDescriptors,\n updaterFn,\n remoteState,\n viewsRef,\n areAnimationsActive,\n isAnimatedProps\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n\n useEffect(() => {\n areAnimationsActive.value = true;\n return () => {\n areAnimationsActive.value = false;\n };\n }, [areAnimationsActive]);\n\n checkSharedValueUsage(initial.value);\n\n if (isJest()) {\n return { viewDescriptors, initial, viewsRef, jestAnimatedStyle };\n } else {\n return { viewDescriptors, initial, viewsRef };\n }\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,QAAQ,SAAS;AAChE,OAAOC,WAAW,IAAIC,sBAAsB,QAAQ,gBAAgB;AACpE,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,iBAAiB,EACjBC,UAAU,EACVC,YAAY,EACZC,sBAAsB,QACjB,SAAS;AAShB,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,uBAAuB;AAC7E,SAASC,MAAM,EAAEC,cAAc,QAAQ,oBAAoB;AAa3D,MAAMC,iBAAiB,GAAGD,cAAc,EAAE;AAkB1C,SAASE,gBAAgBA,CACvBC,cAAsB,EACtBC,YAAgC,EAChCC,aAAiC,EACjCC,SAA6B,EACvB;EACN,SAAS;;EACT,IAAIC,KAAK,CAACC,OAAO,CAACJ,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACK,OAAO,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;MACpCT,gBAAgB,CACdC,cAAc,EACdO,IAAI,EACJL,aAAa,IAAIA,aAAa,CAACM,KAAK,CAAC,EACrCL,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AAE8C,OAAO;MAAEd;IAAS,CAAC;EAC/C;AACF"}
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","makeShareable","startMapper","stopMapper","updateProps","updatePropsJestWrapper","initialUpdaterRun","useSharedValue","buildWorkletsHash","isAnimated","shallowEqual","validateAnimatedStyles","makeViewDescriptorsSet","useViewRefSet","isJest","shouldBeUseWeb","SHOULD_BE_USE_WEB","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","isAnimatedProps","arguments","length","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","global","__frameTimestamp","_getAnimationTimestamp","frame","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","jestStyleUpdater","animatedStyle","adapters","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","animatedUpdaterData","inputs","values","__closure","_dependencies","__DEV__","__workletHash","adaptersArray","adaptersHash","areAnimationsActive","jestAnimatedStyle","push","initialStyle","initial","remoteState","shareableViewDescriptors","fun","updaterFn","adapter","mapperId","animatedStyleHandle"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["'use strict';\nimport type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\nimport { makeShareable, startMapper, stopMapper } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport type {\n AnimatedStyleHandle,\n DefaultStyle,\n DependencyList,\n Descriptor,\n JestAnimatedStyleHandle,\n} from './commonTypes';\nimport type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';\nimport { makeViewDescriptorsSet, useViewRefSet } from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport type {\n AnimationObject,\n Timestamp,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n __AdapterWorkletFunction,\n __BasicWorkletFunction,\n WorkletFunction,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\ninterface AnimatedState {\n last: AnimatedStyle<any>;\n animations: AnimatedStyle<any>;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimatedUpdaterData {\n initial: {\n value: AnimatedStyle<any>;\n updater: () => AnimatedStyle<any>;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle<any>,\n lastAnimation: AnimatedStyle<any>,\n lastValue: AnimatedStyle<any>\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined && lastValue !== null) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle<any>,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle<any>,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n isAnimatedProps = false\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef, isAnimatedProps);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: __BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle<any>>,\n adapters: __AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle<any> = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || _getAnimationTimestamp();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (\n typeof prop === 'object' &&\n prop !== null &&\n prop.value === undefined\n ) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop !== null &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `[Reanimated] Invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\n/**\n * Lets you create a styles object, similar to StyleSheet styles, which can be animated using shared values.\n *\n * @param updater - A function returning an object with style properties you want to animate.\n * @param dependencies - An optional array of dependencies. Only relevant when using Reanimated without the Babel plugin on the Web.\n * @returns An animated style object which has to be passed to the `style` property of an Animated component you want to animate.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedStyle\n */\n// You cannot pass Shared Values to `useAnimatedStyle` directly.\n// @ts-expect-error This overload is required by our API.\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: () => Style,\n dependencies?: DependencyList | null\n): Style;\n\nexport function useAnimatedStyle<Style extends DefaultStyle>(\n updater: WorkletFunction<[], Style>,\n dependencies?: DependencyList | null,\n adapters?: WorkletFunction | WorkletFunction[],\n isAnimatedProps = false\n): AnimatedStyleHandle<Style> | JestAnimatedStyleHandle<Style> {\n const viewsRef: ViewRefSet<unknown> | undefined = useViewRefSet();\n const animatedUpdaterData = useRef<AnimatedUpdaterData>();\n let inputs = Object.values(updater.__closure ?? {});\n if (SHOULD_BE_USE_WEB) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `[Reanimated] \\`useAnimatedStyle\\` was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel plugin.\nFor more, see the docs: \\`https://docs.swmansion.com/react-native-reanimated/docs/guides/web-support#web-without-the-babel-plugin\\`.`\n );\n }\n }\n const adaptersArray = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const areAnimationsActive = useSharedValue<boolean>(true);\n const jestAnimatedStyle = useRef<Style>({} as Style);\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!animatedUpdaterData.current) {\n const initialStyle = initialUpdaterRun(updater);\n if (__DEV__) {\n validateAnimatedStyles(initialStyle);\n }\n animatedUpdaterData.current = {\n initial: {\n value: initialStyle,\n updater,\n },\n remoteState: makeShareable({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n const { initial, remoteState, viewDescriptors } = animatedUpdaterData.current;\n const shareableViewDescriptors = viewDescriptors.shareableViewDescriptors;\n\n dependencies.push(shareableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater;\n if (adapters) {\n updaterFn = (() => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n }) as WorkletFunction<[], Style>;\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n shareableViewDescriptors,\n updater,\n remoteState,\n viewsRef,\n areAnimationsActive,\n jestAnimatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n shareableViewDescriptors,\n updaterFn,\n remoteState,\n viewsRef,\n areAnimationsActive,\n isAnimatedProps\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n\n useEffect(() => {\n areAnimationsActive.value = true;\n return () => {\n areAnimationsActive.value = false;\n };\n }, [areAnimationsActive]);\n\n checkSharedValueUsage(initial.value);\n\n const animatedStyleHandle = useRef<\n AnimatedStyleHandle<Style> | JestAnimatedStyleHandle<Style> | null\n >(null);\n\n if (!animatedStyleHandle.current) {\n animatedStyleHandle.current = isJest()\n ? { viewDescriptors, initial, viewsRef, jestAnimatedStyle }\n : { initial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wB,EACxB/C,OAAO,EACP8C,WAAW,EACXf,QAAQ,EACRU,mBAAmB,EACnBC,iBAAiB,EACjBH,aAAa,CACd;MACH,CAAC;IACH,CAAC,MAAM;MACLS,GAAG,GAAGA,CAAA,KAAM;QACV,SAAS;;QACTlD,YAAY,CACViD,wBAAwB,EACxBE,SAAS,EACTH,WAAW,EACXf,QAAQ,EACRU,mBAAmB,EACnBtC,eAAe,CAChB;MACH,CAAC;IACH;IACA,MAAMgD,QAAQ,GAAGjG,WAAW,CAAC8F,GAAG,EAAEf,MAAM,CAAC;IACzC,OAAO,MAAM;MACX9E,UAAU,CAACgG,QAAQ,CAAC;IACtB,CAAC;IACD;EACF,CAAC,EAAErB,YAAY,CAAC;EAEhB/E,SAAS,CAAC,MAAM;IACd0F,mBAAmB,CAAC5D,KAAK,GAAG,IAAI;IAChC,OAAO,MAAM;MACX4D,mBAAmB,CAAC5D,KAAK,GAAG,KAAK;IACnC,CAAC;EACH,CAAC,EAAE,CAAC4D,mBAAmB,CAAC,CAAC;EAEzBhB,qBAAqB,CAACoB,OAAO,CAAChE,KAAK,CAAC;EAEpC,MAAMuE,mBAAmB,GAAGpG,MAAM,CAEhC,IAAI,CAAC;EAEP,IAAI,CAACoG,mBAAmB,CAACtE,OAAO,EAAE;IAChCsE,mBAAmB,CAACtE,OAAO,GAAGhB,MAAM,EAAE,GAClC;MAAEiC,eAAe;MAAE8C,OAAO;MAAEd,QAAQ;MAAEW;IAAkB,CAAC,GACzD;MAAEG,OAAO;MAAEd,QAAQ;MAAEhC;IAAgB,CAAC;EAC5C;EAEA,OAAOqD,mBAAmB,CAACtE,OAAO;AACpC"}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* with the version used to build the native part of the library in runtime.
|
|
6
6
|
* Remember to keep this in sync with the version declared in `package.json`
|
|
7
7
|
*/
|
|
8
|
-
export const jsVersion = '3.7.
|
|
8
|
+
export const jsVersion = '3.7.1';
|
|
9
9
|
//# sourceMappingURL=jsVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsVersion"],"sources":["jsVersion.ts"],"sourcesContent":["'use strict';\n/**\n * We hardcode the version of Reanimated here in order to compare it\n * with the version used to build the native part of the library in runtime.\n * Remember to keep this in sync with the version declared in `package.json`\n */\nexport const jsVersion = '3.7.
|
|
1
|
+
{"version":3,"names":["jsVersion"],"sources":["jsVersion.ts"],"sourcesContent":["'use strict';\n/**\n * We hardcode the version of Reanimated here in order to compare it\n * with the version used to build the native part of the library in runtime.\n * Remember to keep this in sync with the version declared in `package.json`\n */\nexport const jsVersion = '3.7.1';\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,GAAG,OAAO"}
|
package/package.json
CHANGED
|
@@ -67,17 +67,6 @@ function onlyAnimatedStyles(styles: StyleProps[]): StyleProps[] {
|
|
|
67
67
|
return styles.filter((style) => style?.viewDescriptors);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function isSameAnimatedStyle(
|
|
71
|
-
style1?: StyleProps,
|
|
72
|
-
style2?: StyleProps
|
|
73
|
-
): boolean {
|
|
74
|
-
// We cannot use equality check to compare useAnimatedStyle outputs directly.
|
|
75
|
-
// Instead, we can compare its viewsRefs.
|
|
76
|
-
return style1?.viewsRef === style2?.viewsRef;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const isSameAnimatedProps = isSameAnimatedStyle;
|
|
80
|
-
|
|
81
70
|
type Options<P> = {
|
|
82
71
|
setNativeProps: (ref: AnimatedComponentRef, props: P) => void;
|
|
83
72
|
};
|
|
@@ -401,14 +390,12 @@ export function createAnimatedComponent(
|
|
|
401
390
|
const hasOneSameStyle =
|
|
402
391
|
styles.length === 1 &&
|
|
403
392
|
prevStyles.length === 1 &&
|
|
404
|
-
|
|
393
|
+
styles[0] === prevStyles[0];
|
|
405
394
|
|
|
406
395
|
if (!hasOneSameStyle) {
|
|
407
396
|
// otherwise, remove each style that is not present in new styles
|
|
408
397
|
for (const prevStyle of prevStyles) {
|
|
409
|
-
const isPresent = styles.some((style) =>
|
|
410
|
-
isSameAnimatedStyle(style, prevStyle)
|
|
411
|
-
);
|
|
398
|
+
const isPresent = styles.some((style) => style === prevStyle);
|
|
412
399
|
if (!isPresent) {
|
|
413
400
|
prevStyle.viewDescriptors.remove(viewTag);
|
|
414
401
|
}
|
|
@@ -438,10 +425,7 @@ export function createAnimatedComponent(
|
|
|
438
425
|
});
|
|
439
426
|
|
|
440
427
|
// detach old animatedProps
|
|
441
|
-
if (
|
|
442
|
-
prevAnimatedProps &&
|
|
443
|
-
!isSameAnimatedProps(prevAnimatedProps, this.props.animatedProps)
|
|
444
|
-
) {
|
|
428
|
+
if (prevAnimatedProps && prevAnimatedProps !== this.props.animatedProps) {
|
|
445
429
|
prevAnimatedProps.viewDescriptors!.remove(viewTag as number);
|
|
446
430
|
}
|
|
447
431
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import { initializeSensor, registerSensor, unregisterSensor } from '../core';
|
|
4
4
|
import type {
|
|
5
5
|
SensorConfig,
|
|
@@ -94,12 +94,28 @@ export function useAnimatedSensor(
|
|
|
94
94
|
sensorType: SensorType,
|
|
95
95
|
userConfig?: Partial<SensorConfig>
|
|
96
96
|
): AnimatedSensor<ValueRotation> | AnimatedSensor<Value3D> {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
const userConfigRef = useRef(userConfig);
|
|
98
|
+
|
|
99
|
+
const hasConfigChanged =
|
|
100
|
+
userConfigRef.current?.adjustToInterfaceOrientation !==
|
|
101
|
+
userConfig?.adjustToInterfaceOrientation ||
|
|
102
|
+
userConfigRef.current?.interval !== userConfig?.interval ||
|
|
103
|
+
userConfigRef.current?.iosReferenceFrame !== userConfig?.iosReferenceFrame;
|
|
104
|
+
|
|
105
|
+
if (hasConfigChanged) {
|
|
106
|
+
userConfigRef.current = { ...userConfig };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const config: SensorConfig = useMemo(
|
|
110
|
+
() => ({
|
|
111
|
+
interval: 'auto',
|
|
112
|
+
adjustToInterfaceOrientation: true,
|
|
113
|
+
iosReferenceFrame: IOSReferenceFrame.Auto,
|
|
114
|
+
...userConfigRef.current,
|
|
115
|
+
}),
|
|
116
|
+
[userConfigRef.current]
|
|
117
|
+
);
|
|
118
|
+
|
|
103
119
|
const ref = useRef<AnimatedSensor<Value3D | ValueRotation>>({
|
|
104
120
|
sensor: initializeSensor(sensorType, config),
|
|
105
121
|
unregister: () => {
|
|
@@ -110,11 +126,14 @@ export function useAnimatedSensor(
|
|
|
110
126
|
});
|
|
111
127
|
|
|
112
128
|
useEffect(() => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
ref.current = {
|
|
130
|
+
sensor: initializeSensor(sensorType, config),
|
|
131
|
+
unregister: () => {
|
|
132
|
+
// NOOP
|
|
133
|
+
},
|
|
134
|
+
isAvailable: false,
|
|
135
|
+
config,
|
|
116
136
|
};
|
|
117
|
-
ref.current.sensor = initializeSensor(sensorType, newConfig);
|
|
118
137
|
|
|
119
138
|
const sensorData = ref.current.sensor;
|
|
120
139
|
const adjustToInterfaceOrientation =
|
|
@@ -148,7 +167,7 @@ export function useAnimatedSensor(
|
|
|
148
167
|
return () => {
|
|
149
168
|
ref.current.unregister();
|
|
150
169
|
};
|
|
151
|
-
}, [sensorType,
|
|
170
|
+
}, [sensorType, config]);
|
|
152
171
|
|
|
153
172
|
return ref.current as AnimatedSensor<ValueRotation> | AnimatedSensor<Value3D>;
|
|
154
173
|
}
|
|
@@ -74,7 +74,7 @@ function prepareAnimation(
|
|
|
74
74
|
const animation = animatedProp;
|
|
75
75
|
|
|
76
76
|
let value = animation.current;
|
|
77
|
-
if (lastValue !== undefined) {
|
|
77
|
+
if (lastValue !== undefined && lastValue !== null) {
|
|
78
78
|
if (typeof lastValue === 'object') {
|
|
79
79
|
if (lastValue.value !== undefined) {
|
|
80
80
|
// previously it was a shared value
|
|
@@ -531,9 +531,15 @@ For more, see the docs: \`https://docs.swmansion.com/react-native-reanimated/doc
|
|
|
531
531
|
|
|
532
532
|
checkSharedValueUsage(initial.value);
|
|
533
533
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
534
|
+
const animatedStyleHandle = useRef<
|
|
535
|
+
AnimatedStyleHandle<Style> | JestAnimatedStyleHandle<Style> | null
|
|
536
|
+
>(null);
|
|
537
|
+
|
|
538
|
+
if (!animatedStyleHandle.current) {
|
|
539
|
+
animatedStyleHandle.current = isJest()
|
|
540
|
+
? { viewDescriptors, initial, viewsRef, jestAnimatedStyle }
|
|
541
|
+
: { initial, viewsRef, viewDescriptors };
|
|
538
542
|
}
|
|
543
|
+
|
|
544
|
+
return animatedStyleHandle.current;
|
|
539
545
|
}
|