react-native-reanimated 3.13.0-rc.2 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +8 -2
  2. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +3 -1
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +58 -33
  4. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +19 -9
  5. package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.cpp +11 -7
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.h +14 -6
  7. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +1 -1
  8. package/Common/cpp/NativeModules/NativeReanimatedModule.h +1 -1
  9. package/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp +1 -1
  10. package/Common/cpp/ReanimatedRuntime/WorkletRuntime.h +1 -1
  11. package/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +6 -6
  12. package/Common/cpp/SharedItems/Shareables.cpp +25 -8
  13. package/Common/cpp/SharedItems/Shareables.h +12 -7
  14. package/android/CMakeLists.txt +1 -1
  15. package/android/src/main/cpp/LayoutAnimations.cpp +14 -0
  16. package/android/src/main/cpp/LayoutAnimations.h +5 -0
  17. package/android/src/main/cpp/NativeProxy.cpp +10 -0
  18. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +10 -2
  19. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +2 -0
  20. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +2 -0
  21. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +10 -0
  22. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ScreensHelper.java +83 -0
  23. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +130 -31
  24. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +36 -0
  25. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/TabNavigatorObserver.java +128 -0
  26. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +8 -0
  27. package/android/src/reactNativeVersionPatch/RuntimeExecutor/73/com/swmansion/reanimated/NativeProxy.java +6 -0
  28. package/android/src/reactNativeVersionPatch/RuntimeExecutor/latest/com/swmansion/reanimated/NativeProxy.java +6 -0
  29. package/apple/LayoutReanimation/REAAnimationsManager.h +2 -0
  30. package/apple/LayoutReanimation/REAAnimationsManager.m +5 -0
  31. package/apple/LayoutReanimation/REAScreensHelper.h +6 -0
  32. package/apple/LayoutReanimation/REAScreensHelper.m +92 -4
  33. package/apple/LayoutReanimation/REASharedTransitionManager.h +1 -0
  34. package/apple/LayoutReanimation/REASharedTransitionManager.m +254 -55
  35. package/apple/native/NativeProxy.mm +12 -0
  36. package/lib/module/Colors.js +5 -2
  37. package/lib/module/Colors.js.map +1 -1
  38. package/lib/module/UpdateProps.js +8 -8
  39. package/lib/module/UpdateProps.js.map +1 -1
  40. package/lib/module/ViewDescriptorsSet.js +0 -27
  41. package/lib/module/ViewDescriptorsSet.js.map +1 -1
  42. package/lib/module/createAnimatedComponent/InlinePropManager.js +1 -7
  43. package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
  44. package/lib/module/createAnimatedComponent/PropsFilter.js +1 -6
  45. package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
  46. package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
  47. package/lib/module/createAnimatedComponent/createAnimatedComponent.js +1 -5
  48. package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
  49. package/lib/module/hook/commonTypes.js.map +1 -1
  50. package/lib/module/hook/useAnimatedStyle.js +12 -15
  51. package/lib/module/hook/useAnimatedStyle.js.map +1 -1
  52. package/lib/module/hook/useFrameCallback.js +2 -2
  53. package/lib/module/hook/useFrameCallback.js.map +1 -1
  54. package/lib/module/hook/useWorkletCallback.js +1 -1
  55. package/lib/module/hook/useWorkletCallback.js.map +1 -1
  56. package/lib/module/js-reanimated/index.js +3 -28
  57. package/lib/module/js-reanimated/index.js.map +1 -1
  58. package/lib/module/js-reanimated/webUtils.js +9 -0
  59. package/lib/module/js-reanimated/webUtils.js.map +1 -0
  60. package/lib/module/js-reanimated/webUtils.web.js +25 -0
  61. package/lib/module/js-reanimated/webUtils.web.js.map +1 -0
  62. package/lib/module/layoutReanimation/defaultTransitions/CurvedTransition.js +1 -0
  63. package/lib/module/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  64. package/lib/module/layoutReanimation/defaultTransitions/EntryExitTransition.js +1 -0
  65. package/lib/module/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  66. package/lib/module/layoutReanimation/defaultTransitions/FadingTransition.js +11 -10
  67. package/lib/module/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  68. package/lib/module/layoutReanimation/defaultTransitions/JumpingTransition.js +1 -0
  69. package/lib/module/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  70. package/lib/module/layoutReanimation/defaultTransitions/LinearTransition.js +1 -0
  71. package/lib/module/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  72. package/lib/module/layoutReanimation/defaultTransitions/SequencedTransition.js +1 -0
  73. package/lib/module/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  74. package/lib/module/layoutReanimation/web/Easing.web.js +14 -0
  75. package/lib/module/layoutReanimation/web/Easing.web.js.map +1 -0
  76. package/lib/module/layoutReanimation/web/animationParser.js +16 -1
  77. package/lib/module/layoutReanimation/web/animationParser.js.map +1 -1
  78. package/lib/module/layoutReanimation/web/animationsManager.js +25 -8
  79. package/lib/module/layoutReanimation/web/animationsManager.js.map +1 -1
  80. package/lib/module/layoutReanimation/web/componentStyle.js +12 -16
  81. package/lib/module/layoutReanimation/web/componentStyle.js.map +1 -1
  82. package/lib/module/layoutReanimation/web/componentUtils.js +53 -18
  83. package/lib/module/layoutReanimation/web/componentUtils.js.map +1 -1
  84. package/lib/module/layoutReanimation/web/config.js +1 -12
  85. package/lib/module/layoutReanimation/web/config.js.map +1 -1
  86. package/lib/module/layoutReanimation/web/createAnimation.js +21 -2
  87. package/lib/module/layoutReanimation/web/createAnimation.js.map +1 -1
  88. package/lib/module/layoutReanimation/web/domUtils.js +6 -5
  89. package/lib/module/layoutReanimation/web/domUtils.js.map +1 -1
  90. package/lib/module/layoutReanimation/web/transition/Jumping.web.js +43 -0
  91. package/lib/module/layoutReanimation/web/transition/Jumping.web.js.map +1 -0
  92. package/lib/module/platform-specific/RNRenderer.web.js +1 -1
  93. package/lib/module/platform-specific/RNRenderer.web.js.map +1 -1
  94. package/lib/module/platform-specific/jsVersion.js +1 -1
  95. package/lib/module/platform-specific/jsVersion.js.map +1 -1
  96. package/lib/module/platformFunctions/setNativeProps.web.js +1 -3
  97. package/lib/module/platformFunctions/setNativeProps.web.js.map +1 -1
  98. package/lib/typescript/UpdateProps.d.ts +2 -3
  99. package/lib/typescript/ViewDescriptorsSet.d.ts +0 -9
  100. package/lib/typescript/createAnimatedComponent/commonTypes.d.ts +1 -2
  101. package/lib/typescript/hook/commonTypes.d.ts +3 -6
  102. package/lib/typescript/hook/useWorkletCallback.d.ts +1 -1
  103. package/lib/typescript/js-reanimated/index.d.ts +2 -4
  104. package/lib/typescript/js-reanimated/webUtils.d.ts +3 -0
  105. package/lib/typescript/js-reanimated/webUtils.web.d.ts +3 -0
  106. package/lib/typescript/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +1 -0
  107. package/lib/typescript/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +1 -0
  108. package/lib/typescript/layoutReanimation/defaultTransitions/FadingTransition.d.ts +1 -0
  109. package/lib/typescript/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +1 -0
  110. package/lib/typescript/layoutReanimation/defaultTransitions/LinearTransition.d.ts +1 -0
  111. package/lib/typescript/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +1 -0
  112. package/lib/typescript/layoutReanimation/web/Easing.web.d.ts +10 -0
  113. package/lib/typescript/layoutReanimation/web/animationParser.d.ts +1 -2
  114. package/lib/typescript/layoutReanimation/web/componentStyle.d.ts +1 -1
  115. package/lib/typescript/layoutReanimation/web/componentUtils.d.ts +4 -3
  116. package/lib/typescript/layoutReanimation/web/config.d.ts +5 -12
  117. package/lib/typescript/layoutReanimation/web/createAnimation.d.ts +2 -0
  118. package/lib/typescript/layoutReanimation/web/domUtils.d.ts +1 -1
  119. package/lib/typescript/layoutReanimation/web/transition/Jumping.web.d.ts +29 -0
  120. package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
  121. package/package.json +4 -3
  122. package/src/Colors.ts +5 -2
  123. package/src/UpdateProps.ts +8 -11
  124. package/src/ViewDescriptorsSet.ts +0 -42
  125. package/src/createAnimatedComponent/InlinePropManager.ts +2 -8
  126. package/src/createAnimatedComponent/PropsFilter.tsx +0 -4
  127. package/src/createAnimatedComponent/commonTypes.ts +1 -2
  128. package/src/createAnimatedComponent/createAnimatedComponent.tsx +1 -5
  129. package/src/hook/commonTypes.ts +3 -6
  130. package/src/hook/useAnimatedStyle.ts +9 -26
  131. package/src/hook/useFrameCallback.ts +2 -2
  132. package/src/hook/useWorkletCallback.ts +1 -1
  133. package/src/js-reanimated/index.ts +11 -37
  134. package/src/js-reanimated/webUtils.ts +8 -0
  135. package/src/js-reanimated/webUtils.web.ts +27 -0
  136. package/src/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -0
  137. package/src/layoutReanimation/defaultTransitions/EntryExitTransition.ts +2 -0
  138. package/src/layoutReanimation/defaultTransitions/FadingTransition.ts +12 -10
  139. package/src/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -0
  140. package/src/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -0
  141. package/src/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -0
  142. package/src/layoutReanimation/web/Easing.web.ts +15 -0
  143. package/src/layoutReanimation/web/animationParser.ts +30 -2
  144. package/src/layoutReanimation/web/animationsManager.ts +45 -12
  145. package/src/layoutReanimation/web/componentStyle.ts +13 -16
  146. package/src/layoutReanimation/web/componentUtils.ts +68 -25
  147. package/src/layoutReanimation/web/config.ts +5 -14
  148. package/src/layoutReanimation/web/createAnimation.ts +38 -4
  149. package/src/layoutReanimation/web/domUtils.ts +15 -5
  150. package/src/layoutReanimation/web/transition/Jumping.web.ts +44 -0
  151. package/src/platform-specific/RNRenderer.web.ts +1 -1
  152. package/src/platform-specific/jsVersion.ts +1 -1
  153. package/src/platformFunctions/setNativeProps.web.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["Animations","LayoutAnimationType","getProcessedConfig","handleExitingAnimation","handleLayoutTransition","setElementAnimation","areDOMRectsEqual","makeElementVisible","chooseConfig","animationType","props","config","ENTERING","entering","EXITING","exiting","LAYOUT","layout","checkUndefinedAnimationFail","initialAnimationName","isLayoutTransition","console","warn","maybeReportOverwrittenProperties","keyframe","styles","propertyRegex","animationProperties","Set","match","matchAll","add","commonProperties","Array","from","filter","style","has","length","join","chooseAction","animationConfig","element","transitionData","reversed","tryGetAnimationConfig","animationName","presetName","constructor","shouldFail","startWebLayoutAnimation","tryActivateLayoutTransition","snapshot","rect","getBoundingClientRect","translateX","x","translateY","y","scaleX","width","scaleY","height"],"sources":["animationsManager.ts"],"sourcesContent":["'use strict';\n\nimport type { AnimationConfig, AnimationNames, CustomConfig } from './config';\nimport { Animations } from './config';\nimport type {\n AnimatedComponentProps,\n LayoutAnimationStaticContext,\n} from '../../createAnimatedComponent/commonTypes';\nimport { LayoutAnimationType } from '../animationBuilder/commonTypes';\nimport {\n getProcessedConfig,\n handleExitingAnimation,\n handleLayoutTransition,\n setElementAnimation,\n} from './componentUtils';\nimport { areDOMRectsEqual } from './domUtils';\nimport type { TransitionData } from './animationParser';\nimport { makeElementVisible } from './componentStyle';\n\nfunction chooseConfig<ComponentProps extends Record<string, unknown>>(\n animationType: LayoutAnimationType,\n props: Readonly<AnimatedComponentProps<ComponentProps>>\n) {\n const config =\n animationType === LayoutAnimationType.ENTERING\n ? props.entering\n : animationType === LayoutAnimationType.EXITING\n ? props.exiting\n : animationType === LayoutAnimationType.LAYOUT\n ? props.layout\n : null;\n\n return config;\n}\n\nfunction checkUndefinedAnimationFail(\n initialAnimationName: string,\n isLayoutTransition: boolean\n) {\n // This prevents crashes if we try to set animations that are not defined.\n // We don't care about layout transitions since they're created dynamically\n if (initialAnimationName in Animations || isLayoutTransition) {\n return false;\n }\n\n console.warn(\n \"[Reanimated] Couldn't load entering/exiting animation. Current version supports only predefined animations with modifiers: duration, delay, easing, randomizeDelay, withCallback, reducedMotion.\"\n );\n\n return true;\n}\n\nfunction maybeReportOverwrittenProperties(\n keyframe: string,\n styles: CSSStyleDeclaration\n) {\n const propertyRegex = /([a-zA-Z-]+)(?=:)/g;\n const animationProperties = new Set();\n\n for (const match of keyframe.matchAll(propertyRegex)) {\n animationProperties.add(match[1]);\n }\n\n const commonProperties = Array.from(styles).filter((style) =>\n animationProperties.has(style)\n );\n\n if (commonProperties.length === 0) {\n return;\n }\n\n console.warn(\n `[Reanimated] ${\n commonProperties.length === 1 ? 'Property' : 'Properties'\n } [${commonProperties.join(\n ', '\n )}] may be overwritten by a layout animation. Please wrap your component with an animated view and apply the layout animation on the wrapper.`\n );\n}\n\nfunction chooseAction(\n animationType: LayoutAnimationType,\n animationConfig: AnimationConfig,\n element: HTMLElement,\n transitionData: TransitionData\n) {\n switch (animationType) {\n case LayoutAnimationType.ENTERING:\n setElementAnimation(element, animationConfig);\n break;\n case LayoutAnimationType.LAYOUT:\n transitionData.reversed = animationConfig.reversed;\n handleLayoutTransition(element, animationConfig, transitionData);\n break;\n case LayoutAnimationType.EXITING:\n handleExitingAnimation(element, animationConfig);\n break;\n }\n}\n\nfunction tryGetAnimationConfig<ComponentProps extends Record<string, unknown>>(\n props: Readonly<AnimatedComponentProps<ComponentProps>>,\n animationType: LayoutAnimationType\n) {\n const config = chooseConfig(animationType, props);\n if (!config) {\n return null;\n }\n\n type ConstructorWithStaticContext = LayoutAnimationStaticContext &\n typeof config.constructor;\n\n const isLayoutTransition = animationType === LayoutAnimationType.LAYOUT;\n const animationName =\n typeof config === 'function'\n ? config.presetName\n : (config.constructor as ConstructorWithStaticContext).presetName;\n\n const shouldFail = checkUndefinedAnimationFail(\n animationName,\n isLayoutTransition\n );\n\n if (shouldFail) {\n return null;\n }\n\n const animationConfig = getProcessedConfig(\n animationName,\n animationType,\n config as CustomConfig,\n animationName as AnimationNames\n );\n\n return animationConfig;\n}\n\nexport function startWebLayoutAnimation<\n ComponentProps extends Record<string, unknown>\n>(\n props: Readonly<AnimatedComponentProps<ComponentProps>>,\n element: HTMLElement,\n animationType: LayoutAnimationType,\n transitionData?: TransitionData\n) {\n const animationConfig = tryGetAnimationConfig(props, animationType);\n\n if ((animationConfig?.animationName as AnimationNames) in Animations) {\n maybeReportOverwrittenProperties(\n Animations[animationConfig?.animationName as AnimationNames].style,\n element.style\n );\n }\n\n if (animationConfig) {\n chooseAction(\n animationType,\n animationConfig,\n element,\n transitionData as TransitionData\n );\n } else {\n makeElementVisible(element, 0);\n }\n}\n\nexport function tryActivateLayoutTransition<\n ComponentProps extends Record<string, unknown>\n>(\n props: Readonly<AnimatedComponentProps<ComponentProps>>,\n element: HTMLElement,\n snapshot: DOMRect\n) {\n if (!props.layout) {\n return;\n }\n\n const rect = element.getBoundingClientRect();\n\n if (areDOMRectsEqual(rect, snapshot)) {\n return;\n }\n\n const transitionData: TransitionData = {\n translateX: snapshot.x - rect.x,\n translateY: snapshot.y - rect.y,\n scaleX: snapshot.width / rect.width,\n scaleY: snapshot.height / rect.height,\n reversed: false, // This field is used only in `SequencedTransition`, so by default it will be false\n };\n\n startWebLayoutAnimation(\n props,\n element,\n LayoutAnimationType.LAYOUT,\n transitionData\n );\n}\n"],"mappings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EAC1B2B,cACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["Animations","LayoutAnimationType","createCustomKeyFrameAnimation","getProcessedConfig","handleExitingAnimation","handleLayoutTransition","maybeModifyStyleForKeyframe","setElementAnimation","areDOMRectsEqual","Keyframe","makeElementVisible","chooseConfig","animationType","props","config","ENTERING","entering","EXITING","exiting","LAYOUT","layout","checkUndefinedAnimationFail","initialAnimationName","needsCustomization","console","warn","maybeReportOverwrittenProperties","keyframe","styles","propertyRegex","animationProperties","Set","match","matchAll","add","commonProperties","Array","from","filter","style","has","length","join","chooseAction","animationConfig","element","transitionData","reversed","tryGetAnimationConfig","isLayoutTransition","isCustomKeyframe","animationName","definitions","presetName","constructor","shouldFail","keyframeTimestamps","Object","keys","includes","startWebLayoutAnimation","tryActivateLayoutTransition","snapshot","rect","getBoundingClientRect","translateX","x","translateY","y","scaleX","width","scaleY","height"],"sources":["animationsManager.ts"],"sourcesContent":["'use strict';\n\nimport type {\n AnimationConfig,\n AnimationNames,\n CustomConfig,\n KeyframeDefinitions,\n} from './config';\nimport { Animations } from './config';\nimport type {\n AnimatedComponentProps,\n LayoutAnimationStaticContext,\n} from '../../createAnimatedComponent/commonTypes';\nimport { LayoutAnimationType } from '../animationBuilder/commonTypes';\nimport { createCustomKeyFrameAnimation } from './createAnimation';\nimport {\n getProcessedConfig,\n handleExitingAnimation,\n handleLayoutTransition,\n maybeModifyStyleForKeyframe,\n setElementAnimation,\n} from './componentUtils';\nimport { areDOMRectsEqual } from './domUtils';\nimport type { TransitionData } from './animationParser';\nimport { Keyframe } from '../animationBuilder';\nimport { makeElementVisible } from './componentStyle';\n\nfunction chooseConfig<ComponentProps extends Record<string, unknown>>(\n animationType: LayoutAnimationType,\n props: Readonly<AnimatedComponentProps<ComponentProps>>\n) {\n const config =\n animationType === LayoutAnimationType.ENTERING\n ? props.entering\n : animationType === LayoutAnimationType.EXITING\n ? props.exiting\n : animationType === LayoutAnimationType.LAYOUT\n ? props.layout\n : null;\n\n return config;\n}\n\nfunction checkUndefinedAnimationFail(\n initialAnimationName: string,\n needsCustomization: boolean\n) {\n // This prevents crashes if we try to set animations that are not defined.\n // We don't care about layout transitions or custom keyframes since they're created dynamically\n if (initialAnimationName in Animations || needsCustomization) {\n return false;\n }\n\n console.warn(\n \"[Reanimated] Couldn't load entering/exiting animation. Current version supports only predefined animations with modifiers: duration, delay, easing, randomizeDelay, withCallback, reducedMotion.\"\n );\n\n return true;\n}\n\nfunction maybeReportOverwrittenProperties(\n keyframe: string,\n styles: CSSStyleDeclaration\n) {\n const propertyRegex = /([a-zA-Z-]+)(?=:)/g;\n const animationProperties = new Set();\n\n for (const match of keyframe.matchAll(propertyRegex)) {\n animationProperties.add(match[1]);\n }\n\n const commonProperties = Array.from(styles).filter((style) =>\n animationProperties.has(style)\n );\n\n if (commonProperties.length === 0) {\n return;\n }\n\n console.warn(\n `[Reanimated] ${\n commonProperties.length === 1 ? 'Property' : 'Properties'\n } [${commonProperties.join(\n ', '\n )}] may be overwritten by a layout animation. Please wrap your component with an animated view and apply the layout animation on the wrapper.`\n );\n}\n\nfunction chooseAction(\n animationType: LayoutAnimationType,\n animationConfig: AnimationConfig,\n element: HTMLElement,\n transitionData: TransitionData\n) {\n switch (animationType) {\n case LayoutAnimationType.ENTERING:\n setElementAnimation(element, animationConfig, true);\n break;\n case LayoutAnimationType.LAYOUT:\n transitionData.reversed = animationConfig.reversed;\n handleLayoutTransition(element, animationConfig, transitionData);\n break;\n case LayoutAnimationType.EXITING:\n handleExitingAnimation(element, animationConfig);\n break;\n }\n}\n\nfunction tryGetAnimationConfig<ComponentProps extends Record<string, unknown>>(\n props: Readonly<AnimatedComponentProps<ComponentProps>>,\n animationType: LayoutAnimationType\n) {\n const config = chooseConfig(animationType, props);\n if (!config) {\n return null;\n }\n\n type ConstructorWithStaticContext = LayoutAnimationStaticContext &\n typeof config.constructor;\n\n const isLayoutTransition = animationType === LayoutAnimationType.LAYOUT;\n const isCustomKeyframe = config instanceof Keyframe;\n\n let animationName;\n\n if (isCustomKeyframe) {\n animationName = createCustomKeyFrameAnimation(\n (config as CustomConfig).definitions as KeyframeDefinitions\n );\n } else if (typeof config === 'function') {\n animationName = config.presetName;\n } else {\n animationName = (config.constructor as ConstructorWithStaticContext)\n .presetName;\n }\n\n const shouldFail = checkUndefinedAnimationFail(\n animationName,\n isLayoutTransition || isCustomKeyframe\n );\n\n if (shouldFail) {\n return null;\n }\n\n if (isCustomKeyframe) {\n const keyframeTimestamps = Object.keys(\n (config as CustomConfig).definitions as KeyframeDefinitions\n );\n\n if (\n !(keyframeTimestamps.includes('100') || keyframeTimestamps.includes('to'))\n ) {\n console.warn(\n `[Reanimated] Neither '100' nor 'to' was specified in Keyframe definition. This may result in wrong final position of your component. One possible solution is to duplicate last timestamp in definition as '100' (or 'to')`\n );\n }\n }\n\n const animationConfig = getProcessedConfig(\n animationName,\n animationType,\n config as CustomConfig\n );\n\n return animationConfig;\n}\n\nexport function startWebLayoutAnimation<\n ComponentProps extends Record<string, unknown>\n>(\n props: Readonly<AnimatedComponentProps<ComponentProps>>,\n element: HTMLElement,\n animationType: LayoutAnimationType,\n transitionData?: TransitionData\n) {\n const animationConfig = tryGetAnimationConfig(props, animationType);\n\n maybeModifyStyleForKeyframe(element, props.entering as CustomConfig);\n\n if ((animationConfig?.animationName as AnimationNames) in Animations) {\n maybeReportOverwrittenProperties(\n Animations[animationConfig?.animationName as AnimationNames].style,\n element.style\n );\n }\n\n if (animationConfig) {\n chooseAction(\n animationType,\n animationConfig,\n element,\n transitionData as TransitionData\n );\n } else {\n makeElementVisible(element, 0);\n }\n}\n\nexport function tryActivateLayoutTransition<\n ComponentProps extends Record<string, unknown>\n>(\n props: Readonly<AnimatedComponentProps<ComponentProps>>,\n element: HTMLElement,\n snapshot: DOMRect\n) {\n if (!props.layout) {\n return;\n }\n\n const rect = element.getBoundingClientRect();\n\n if (areDOMRectsEqual(rect, snapshot)) {\n return;\n }\n\n const transitionData: TransitionData = {\n translateX: snapshot.x - rect.x,\n translateY: snapshot.y - rect.y,\n scaleX: snapshot.width / rect.width,\n scaleY: snapshot.height / rect.height,\n reversed: false, // This field is used only in `SequencedTransition`, so by default it will be false\n };\n\n startWebLayoutAnimation(\n props,\n element,\n LayoutAnimationType.LAYOUT,\n transitionData\n );\n}\n"],"mappings":"AAAA,YAAY;;AAQZ,SAASA,UAAU,QAAQ,UAAU;AAKrC,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,6BAA6B,QAAQ,mBAAmB;AACjE,SACEC,kBAAkB,EAClBC,sBAAsB,EACtBC,sBAAsB,EACtBC,2BAA2B,EAC3BC,mBAAmB,QACd,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,kBAAkB,QAAQ,kBAAkB;AAErD,SAASC,YAAYA,CACnBC,aAAkC,EAClCC,KAAuD,EACvD;EACA,MAAMC,MAAM,GACVF,aAAa,KAAKX,mBAAmB,CAACc,QAAQ,GAC1CF,KAAK,CAACG,QAAQ,GACdJ,aAAa,KAAKX,mBAAmB,CAACgB,OAAO,GAC7CJ,KAAK,CAACK,OAAO,GACbN,aAAa,KAAKX,mBAAmB,CAACkB,MAAM,GAC5CN,KAAK,CAACO,MAAM,GACZ,IAAI;EAEV,OAAON,MAAM;AACf;AAEA,SAASO,2BAA2BA,CAClCC,oBAA4B,EAC5BC,kBAA2B,EAC3B;EACA;EACA;EACA,IAAID,oBAAoB,IAAItB,UAAU,IAAIuB,kBAAkB,EAAE;IAC5D,OAAO,KAAK;EACd;EAEAC,OAAO,CAACC,IAAI,CACV,kMACF,CAAC;EAED,OAAO,IAAI;AACb;AAEA,SAASC,gCAAgCA,CACvCC,QAAgB,EAChBC,MAA2B,EAC3B;EACA,MAAMC,aAAa,GAAG,oBAAoB;EAC1C,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAC,CAAC;EAErC,KAAK,MAAMC,KAAK,IAAIL,QAAQ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K,EAClEM,OAAO,CAACN,KACV,CAAC;EACH;EAEA,IAAIK,eAAe,EAAE;IACnBD,YAAY,CACV/B,aAAa,EACbgC,eAAe,EACfC,OAAO,EACPC,cACF,CAAC;EACH,CAAC,MAAM;IACLpC,kBAAkB,CAACmC,OAAO,EAAE,CAAC,CAAC;EAChC;AACF;AAEA,OAAO,SAASgB,2BAA2BA,CAGzChD,KAAuD,EACvDgC,OAAoB,EACpBiB,QAAiB,EACjB;EACA,IAAI,CAACjD,KAAK,CAACO,MAAM,EAAE;IACjB;EACF;EAEA,MAAM2C,IAAI,GAAGlB,OAAO,CAACmB,qBAAqB,CAAC,CAAC;EAE5C,IAAIxD,gBAAgB,CAACuD,IAAI,EAAED,QAAQ,CAAC,EAAE;IACpC;EACF;EAEA,MAAMhB,cAA8B,GAAG;IACrCmB,UAAU,EAAEH,QAAQ,CAACI,CAAC,GAAGH,IAAI,CAACG,CAAC;IAC/BC,UAAU,EAAEL,QAAQ,CAACM,CAAC,GAAGL,IAAI,CAACK,CAAC;IAC/BC,MAAM,EAAEP,QAAQ,CAACQ,KAAK,GAAGP,IAAI,CAACO,KAAK;IACnCC,MAAM,EAAET,QAAQ,CAACU,MAAM,GAAGT,IAAI,CAACS,MAAM;IACrCzB,QAAQ,EAAE,KAAK,CAAE;EACnB,CAAC;EAEDa,uBAAuB,CACrB/C,KAAK,EACLgC,OAAO,EACP5C,mBAAmB,CAACkB,MAAM,EAC1B2B,cACF,CAAC;AACH","ignoreList":[]}
@@ -6,16 +6,12 @@ export function makeElementVisible(element, delay) {
6
6
  if (delay === 0) {
7
7
  _updatePropsJS({
8
8
  visibility: 'initial'
9
- }, {
10
- _component: element
11
- });
9
+ }, element);
12
10
  } else {
13
11
  setTimeout(() => {
14
12
  _updatePropsJS({
15
13
  visibility: 'initial'
16
- }, {
17
- _component: element
18
- });
14
+ }, element);
19
15
  }, delay * 1000);
20
16
  }
21
17
  }
@@ -34,17 +30,17 @@ function fixElementPosition(element, parent, snapshot) {
34
30
  element.style.left = `${snapshot.left - parentRect.left - parentBorderLeftValue}px`;
35
31
  }
36
32
  }
37
- export function setDummyPosition(dummy, snapshot) {
38
- dummy.style.transform = '';
39
- dummy.style.position = 'absolute';
40
- dummy.style.top = `${snapshot.top}px`;
41
- dummy.style.left = `${snapshot.left}px`;
42
- dummy.style.width = `${snapshot.width}px`;
43
- dummy.style.height = `${snapshot.height}px`;
44
- dummy.style.margin = '0px'; // tmpElement has absolute position, so margin is not necessary
33
+ export function setElementPosition(element, snapshot) {
34
+ element.style.transform = '';
35
+ element.style.position = 'absolute';
36
+ element.style.top = `${snapshot.top}px`;
37
+ element.style.left = `${snapshot.left}px`;
38
+ element.style.width = `${snapshot.width}px`;
39
+ element.style.height = `${snapshot.height}px`;
40
+ element.style.margin = '0px'; // tmpElement has absolute position, so margin is not necessary
45
41
 
46
- if (dummy.parentElement) {
47
- fixElementPosition(dummy, dummy.parentElement, snapshot);
42
+ if (element.parentElement) {
43
+ fixElementPosition(element, element.parentElement, snapshot);
48
44
  }
49
45
  }
50
46
  //# sourceMappingURL=componentStyle.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_updatePropsJS","snapshots","WeakMap","makeElementVisible","element","delay","visibility","_component","setTimeout","fixElementPosition","parent","snapshot","parentRect","getBoundingClientRect","parentBorderTopValue","parseInt","getComputedStyle","borderTopWidth","parentBorderLeftValue","borderLeftWidth","dummyRect","top","style","left","setDummyPosition","dummy","transform","position","width","height","margin","parentElement"],"sources":["componentStyle.ts"],"sourcesContent":["'use strict';\n\nimport { _updatePropsJS } from '../../js-reanimated';\nimport type { ReanimatedHTMLElement } from '../../js-reanimated';\n\nexport interface ReanimatedSnapshot {\n top: number;\n left: number;\n width: number;\n height: number;\n scrollOffsets: ScrollOffsets;\n}\n\nexport interface ScrollOffsets {\n scrollTopOffset: number;\n scrollLeftOffset: number;\n}\n\nexport const snapshots = new WeakMap<HTMLElement, ReanimatedSnapshot>();\n\nexport function makeElementVisible(element: HTMLElement, delay: number) {\n if (delay === 0) {\n _updatePropsJS(\n { visibility: 'initial' },\n { _component: element as ReanimatedHTMLElement }\n );\n } else {\n setTimeout(() => {\n _updatePropsJS(\n { visibility: 'initial' },\n { _component: element as ReanimatedHTMLElement }\n );\n }, delay * 1000);\n }\n}\n\nfunction fixElementPosition(\n element: HTMLElement,\n parent: HTMLElement,\n snapshot: ReanimatedSnapshot\n) {\n const parentRect = parent.getBoundingClientRect();\n\n const parentBorderTopValue = parseInt(\n getComputedStyle(parent).borderTopWidth\n );\n\n const parentBorderLeftValue = parseInt(\n getComputedStyle(parent).borderLeftWidth\n );\n\n const dummyRect = element.getBoundingClientRect();\n // getBoundingClientRect returns DOMRect with position of the element with respect to document body.\n // However, using position `absolute` doesn't guarantee, that the dummy will be placed relative to body element.\n // The trick below allows us to once again get position relative to body, by comparing snapshot with new position of the dummy.\n if (dummyRect.top !== snapshot.top) {\n element.style.top = `${\n snapshot.top - parentRect.top - parentBorderTopValue\n }px`;\n }\n\n if (dummyRect.left !== snapshot.left) {\n element.style.left = `${\n snapshot.left - parentRect.left - parentBorderLeftValue\n }px`;\n }\n}\n\nexport function setDummyPosition(\n dummy: HTMLElement,\n snapshot: ReanimatedSnapshot\n) {\n dummy.style.transform = '';\n dummy.style.position = 'absolute';\n dummy.style.top = `${snapshot.top}px`;\n dummy.style.left = `${snapshot.left}px`;\n dummy.style.width = `${snapshot.width}px`;\n dummy.style.height = `${snapshot.height}px`;\n dummy.style.margin = '0px'; // tmpElement has absolute position, so margin is not necessary\n\n if (dummy.parentElement) {\n fixElementPosition(dummy, dummy.parentElement, snapshot);\n }\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,cAAc,QAAQ,qBAAqB;AAgBpD,OAAO,MAAMC,SAAS,GAAG,IAAIC,OAAO,CAAkC,CAAC;AAEvE,OAAO,SAASC,kBAAkBA,CAACC,OAAoB,EAAEC,KAAa,EAAE;EACtE,IAAIA,KAAK,KAAK,CAAC,EAAE;IACfL,cAAc,CACZ;M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I,GAAEV,QAAQ,CAACU,GAAI,IAAG;EACrCI,KAAK,CAACH,KAAK,CAACC,IAAI,GAAI,GAAEZ,QAAQ,CAACY,IAAK,IAAG;EACvCE,KAAK,CAACH,KAAK,CAACM,KAAK,GAAI,GAAEjB,QAAQ,CAACiB,KAAM,IAAG;EACzCH,KAAK,CAACH,KAAK,CAACO,MAAM,GAAI,GAAElB,QAAQ,CAACkB,MAAO,IAAG;EAC3CJ,KAAK,CAACH,KAAK,CAACQ,MAAM,GAAG,KAAK,CAAC,CAAC;;EAE5B,IAAIL,KAAK,CAACM,aAAa,EAAE;IACvBtB,kBAAkB,CAACgB,KAAK,EAAEA,KAAK,CAACM,aAAa,EAAEpB,QAAQ,CAAC;EAC1D;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_updatePropsJS","snapshots","WeakMap","makeElementVisible","element","delay","visibility","setTimeout","fixElementPosition","parent","snapshot","parentRect","getBoundingClientRect","parentBorderTopValue","parseInt","getComputedStyle","borderTopWidth","parentBorderLeftValue","borderLeftWidth","dummyRect","top","style","left","setElementPosition","transform","position","width","height","margin","parentElement"],"sources":["componentStyle.ts"],"sourcesContent":["'use strict';\n\nimport { _updatePropsJS } from '../../js-reanimated';\nimport type { ReanimatedHTMLElement } from '../../js-reanimated';\n\nexport interface ReanimatedSnapshot {\n top: number;\n left: number;\n width: number;\n height: number;\n scrollOffsets: ScrollOffsets;\n}\n\nexport interface ScrollOffsets {\n scrollTopOffset: number;\n scrollLeftOffset: number;\n}\n\nexport const snapshots = new WeakMap<HTMLElement, ReanimatedSnapshot>();\n\nexport function makeElementVisible(element: HTMLElement, delay: number) {\n if (delay === 0) {\n _updatePropsJS({ visibility: 'initial' }, element as ReanimatedHTMLElement);\n } else {\n setTimeout(() => {\n _updatePropsJS(\n { visibility: 'initial' },\n element as ReanimatedHTMLElement\n );\n }, delay * 1000);\n }\n}\n\nfunction fixElementPosition(\n element: HTMLElement,\n parent: HTMLElement,\n snapshot: ReanimatedSnapshot\n) {\n const parentRect = parent.getBoundingClientRect();\n\n const parentBorderTopValue = parseInt(\n getComputedStyle(parent).borderTopWidth\n );\n\n const parentBorderLeftValue = parseInt(\n getComputedStyle(parent).borderLeftWidth\n );\n\n const dummyRect = element.getBoundingClientRect();\n // getBoundingClientRect returns DOMRect with position of the element with respect to document body.\n // However, using position `absolute` doesn't guarantee, that the dummy will be placed relative to body element.\n // The trick below allows us to once again get position relative to body, by comparing snapshot with new position of the dummy.\n if (dummyRect.top !== snapshot.top) {\n element.style.top = `${\n snapshot.top - parentRect.top - parentBorderTopValue\n }px`;\n }\n\n if (dummyRect.left !== snapshot.left) {\n element.style.left = `${\n snapshot.left - parentRect.left - parentBorderLeftValue\n }px`;\n }\n}\n\nexport function setElementPosition(\n element: HTMLElement,\n snapshot: ReanimatedSnapshot\n) {\n element.style.transform = '';\n element.style.position = 'absolute';\n element.style.top = `${snapshot.top}px`;\n element.style.left = `${snapshot.left}px`;\n element.style.width = `${snapshot.width}px`;\n element.style.height = `${snapshot.height}px`;\n element.style.margin = '0px'; // tmpElement has absolute position, so margin is not necessary\n\n if (element.parentElement) {\n fixElementPosition(element, element.parentElement, snapshot);\n }\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,cAAc,QAAQ,qBAAqB;AAgBpD,OAAO,MAAMC,SAAS,GAAG,IAAIC,OAAO,CAAkC,CAAC;AAEvE,OAAO,SAASC,kBAAkBA,CAACC,OAAoB,EAAEC,KAAa,EAAE;EACtE,IAAIA,KAAK,KAAK,CAAC,EAAE;IACfL,cAAc,CAAC;MAAEM,UAAU,EAAE;IAAU,CAAC,EAAEF,OAAgC,CAAC;EAC7E,CAAC,MAAM;IACLG,UAAU,CAAC,MAAM;MACfP,cAAc,CACZ;QAAEM,UAAU,EAAE;MAAU,CAAC,EACzBF,OACF,CAAC;IACH,CAAC,EAAEC,KAAK,GAAG,IAAI,CAAC;EAClB;AACF;AAEA,SAASG,kBAAkBA,CACzBJ,OAAoB,EACpBK,MAAmB,EACnBC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AG,KAAK,CAAC,CAAC;;EAE9B,IAAIxB,OAAO,CAACyB,aAAa,EAAE;IACzBrB,kBAAkB,CAACJ,OAAO,EAAEA,OAAO,CAACyB,aAAa,EAAEnB,QAAQ,CAAC;EAC9D;AACF","ignoreList":[]}
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
- import { Animations, TransitionType, WebEasings } from './config';
3
+ import { Animations, TransitionType } from './config';
4
+ import { WebEasings } from './Easing.web';
4
5
  import { TransitionGenerator } from './createAnimation';
5
6
  import { scheduleAnimationCleanup } from './domUtils';
6
7
  import { _updatePropsJS } from '../../js-reanimated';
7
8
  import { ReduceMotion } from '../../commonTypes';
8
9
  import { isReducedMotion } from '../../PlatformChecker';
9
10
  import { LayoutAnimationType } from '../animationBuilder/commonTypes';
10
- import { setDummyPosition, snapshots } from './componentStyle';
11
+ import { setElementPosition, snapshots } from './componentStyle';
12
+ import { Keyframe } from '../animationBuilder';
11
13
  function getEasingFromConfig(config) {
12
14
  const easingName = config.easingV && config.easingV.name in WebEasings ? config.easingV.name : 'linear';
13
15
  return `cubic-bezier(${WebEasings[easingName].toString()})`;
@@ -36,8 +38,11 @@ export function getReducedMotionFromConfig(config) {
36
38
  return isReducedMotion();
37
39
  }
38
40
  }
39
- function getDurationFromConfig(config, isLayoutTransition, animationName) {
40
- const defaultDuration = isLayoutTransition ? 0.3 : Animations[animationName].duration;
41
+ function getDurationFromConfig(config, animationName) {
42
+ // Duration in keyframe has to be in seconds. However, when using `.duration()` modifier we pass it in miliseconds.
43
+ // If `duration` was specified in config, we have to divide it by `1000`, otherwise we return value that is already in seconds.
44
+
45
+ const defaultDuration = animationName in Animations ? Animations[animationName].duration : 0.3;
41
46
  return config.durationV !== undefined ? config.durationV / 1000 : defaultDuration;
42
47
  }
43
48
  function getCallbackFromConfig(config) {
@@ -46,17 +51,32 @@ function getCallbackFromConfig(config) {
46
51
  function getReversedFromConfig(config) {
47
52
  return !!config.reversed;
48
53
  }
49
- export function getProcessedConfig(animationName, animationType, config, initialAnimationName) {
54
+ export function getProcessedConfig(animationName, animationType, config) {
50
55
  return {
51
56
  animationName,
52
57
  animationType,
53
- duration: getDurationFromConfig(config, animationType === LayoutAnimationType.LAYOUT, initialAnimationName),
58
+ duration: getDurationFromConfig(config, animationName),
54
59
  delay: getDelayFromConfig(config),
55
60
  easing: getEasingFromConfig(config),
56
61
  callback: getCallbackFromConfig(config),
57
62
  reversed: getReversedFromConfig(config)
58
63
  };
59
64
  }
65
+ export function maybeModifyStyleForKeyframe(element, config) {
66
+ if (!(config instanceof Keyframe)) {
67
+ return;
68
+ }
69
+
70
+ // We need to set `animationFillMode` to `forwards`, otherwise component will go back to its position.
71
+ // This will result in wrong snapshot
72
+ element.style.animationFillMode = 'forwards';
73
+ for (const timestampRules of Object.values(config.definitions)) {
74
+ if ('originX' in timestampRules || 'originY' in timestampRules) {
75
+ element.style.position = 'absolute';
76
+ return;
77
+ }
78
+ }
79
+ }
60
80
  export function saveSnapshot(element) {
61
81
  const rect = element.getBoundingClientRect();
62
82
  const snapshot = {
@@ -68,19 +88,31 @@ export function saveSnapshot(element) {
68
88
  };
69
89
  snapshots.set(element, snapshot);
70
90
  }
71
- export function setElementAnimation(element, animationConfig) {
91
+ export function setElementAnimation(element, animationConfig, shouldSavePosition = false) {
72
92
  const {
73
93
  animationName,
74
94
  duration,
75
95
  delay,
76
96
  easing
77
97
  } = animationConfig;
78
- element.style.animationName = animationName;
79
- element.style.animationDuration = `${duration}s`;
80
- element.style.animationDelay = `${delay}s`;
81
- element.style.animationTimingFunction = easing;
98
+ const configureAnimation = () => {
99
+ element.style.animationName = animationName;
100
+ element.style.animationDuration = `${duration}s`;
101
+ element.style.animationDelay = `${delay}s`;
102
+ element.style.animationTimingFunction = easing;
103
+ };
104
+ if (animationConfig.animationType === LayoutAnimationType.ENTERING) {
105
+ // On chrome sometimes entering animations flicker. This is most likely caused by animation being interrupted
106
+ // by already started tasks. To avoid flickering, we use `requestAnimationFrame`, which will run callback right before repaint.
107
+ requestAnimationFrame(configureAnimation);
108
+ } else {
109
+ configureAnimation();
110
+ }
82
111
  element.onanimationend = () => {
83
112
  var _animationConfig$call;
113
+ if (shouldSavePosition) {
114
+ saveSnapshot(element);
115
+ }
84
116
  (_animationConfig$call = animationConfig.callback) === null || _animationConfig$call === void 0 || _animationConfig$call.call(animationConfig, true);
85
117
  element.removeEventListener('animationcancel', animationCancelHandler);
86
118
  };
@@ -95,14 +127,16 @@ export function setElementAnimation(element, animationConfig) {
95
127
  if (animationConfig.animationType === LayoutAnimationType.ENTERING) {
96
128
  _updatePropsJS({
97
129
  visibility: 'initial'
98
- }, {
99
- _component: element
100
- });
130
+ }, element);
101
131
  }
102
132
  element.addEventListener('animationcancel', animationCancelHandler);
103
133
  };
104
134
  if (!(animationName in Animations)) {
105
- scheduleAnimationCleanup(animationName, duration + delay);
135
+ scheduleAnimationCleanup(animationName, duration + delay, () => {
136
+ if (shouldSavePosition) {
137
+ setElementPosition(element, snapshots.get(element));
138
+ }
139
+ });
106
140
  }
107
141
  }
108
142
  export function handleLayoutTransition(element, animationConfig, transitionData) {
@@ -120,6 +154,9 @@ export function handleLayoutTransition(element, animationConfig, transitionData)
120
154
  case 'FadingTransition':
121
155
  animationType = TransitionType.FADING;
122
156
  break;
157
+ case 'JumpingTransition':
158
+ animationType = TransitionType.JUMPING;
159
+ break;
123
160
  default:
124
161
  animationType = TransitionType.LINEAR;
125
162
  break;
@@ -149,8 +186,6 @@ export function handleExitingAnimation(element, animationConfig) {
149
186
  const dummy = element.cloneNode();
150
187
  dummy.reanimatedDummy = true;
151
188
  element.style.animationName = '';
152
- // We hide current element so only its copy with proper animation will be displayed
153
- element.style.visibility = 'hidden';
154
189
 
155
190
  // After cloning the element, we want to move all children from original element to its clone. This is because original element
156
191
  // will be unmounted, therefore when this code executes in child component, parent will be either empty or removed soon.
@@ -181,7 +216,7 @@ export function handleExitingAnimation(element, animationConfig) {
181
216
  snapshot.left += lastScrollLeftOffset - currentScrollLeftOffset;
182
217
  }
183
218
  snapshots.set(dummy, snapshot);
184
- setDummyPosition(dummy, snapshot);
219
+ setElementPosition(dummy, snapshot);
185
220
  const originalOnAnimationEnd = dummy.onanimationend;
186
221
  dummy.onanimationend = function (event) {
187
222
  if (parent !== null && parent !== void 0 && parent.contains(dummy)) {
@@ -1 +1 @@
1
- {"version":3,"names":["Animations","TransitionType","WebEasings","TransitionGenerator","scheduleAnimationCleanup","_updatePropsJS","ReduceMotion","isReducedMotion","LayoutAnimationType","setDummyPosition","snapshots","getEasingFromConfig","config","easingName","easingV","name","toString","getRandomDelay","maxDelay","Math","floor","random","getDelayFromConfig","shouldRandomizeDelay","randomizeDelay","delay","delayV","getReducedMotionFromConfig","reduceMotionV","Never","Always","getDurationFromConfig","isLayoutTransition","animationName","defaultDuration","duration","durationV","undefined","getCallbackFromConfig","callbackV","getReversedFromConfig","reversed","getProcessedConfig","animationType","initialAnimationName","LAYOUT","easing","callback","saveSnapshot","element","rect","getBoundingClientRect","snapshot","top","left","width","height","scrollOffsets","getElementScrollValue","set","setElementAnimation","animationConfig","style","animationDuration","animationDelay","animationTimingFunction","onanimationend","_animationConfig$call","call","removeEventListener","animationCancelHandler","_animationConfig$call2","onanimationstart","ENTERING","visibility","_component","addEventListener","handleLayoutTransition","transitionData","LINEAR","SEQUENCED","FADING","current","scrollTopOffset","scrollLeftOffset","scrollTop","scrollLeft","parentElement","handleExitingAnimation","parent","offsetParent","dummy","cloneNode","reanimatedDummy","firstChild","appendChild","get","currentScrollTopOffset","lastScrollTopOffset","currentScrollLeftOffset","lastScrollLeftOffset","originalOnAnimationEnd","event","contains","removedAfterAnimation","removeChild"],"sources":["componentUtils.ts"],"sourcesContent":["'use strict';\n\nimport { Animations, TransitionType, WebEasings } from './config';\nimport type {\n AnimationCallback,\n AnimationConfig,\n AnimationNames,\n CustomConfig,\n WebEasingsNames,\n} from './config';\nimport type { TransitionData } from './animationParser';\nimport { TransitionGenerator } from './createAnimation';\nimport { scheduleAnimationCleanup } from './domUtils';\nimport { _updatePropsJS } from '../../js-reanimated';\nimport type { ReanimatedHTMLElement } from '../../js-reanimated';\nimport { ReduceMotion } from '../../commonTypes';\nimport { isReducedMotion } from '../../PlatformChecker';\nimport { LayoutAnimationType } from '../animationBuilder/commonTypes';\nimport type { ReanimatedSnapshot, ScrollOffsets } from './componentStyle';\nimport { setDummyPosition, snapshots } from './componentStyle';\n\nfunction getEasingFromConfig(config: CustomConfig): string {\n const easingName =\n config.easingV && config.easingV.name in WebEasings\n ? (config.easingV.name as WebEasingsNames)\n : 'linear';\n\n return `cubic-bezier(${WebEasings[easingName].toString()})`;\n}\n\nfunction getRandomDelay(maxDelay = 1000) {\n return Math.floor(Math.random() * (maxDelay + 1)) / 1000;\n}\n\nfunction getDelayFromConfig(config: CustomConfig): number {\n const shouldRandomizeDelay = config.randomizeDelay;\n\n const delay = shouldRandomizeDelay ? getRandomDelay() : 0;\n\n if (!config.delayV) {\n return delay;\n }\n\n return shouldRandomizeDelay\n ? getRandomDelay(config.delayV)\n : config.delayV / 1000;\n}\n\nexport function getReducedMotionFromConfig(config: CustomConfig) {\n if (!config.reduceMotionV) {\n return isReducedMotion();\n }\n\n switch (config.reduceMotionV) {\n case ReduceMotion.Never:\n return false;\n case ReduceMotion.Always:\n return true;\n default:\n return isReducedMotion();\n }\n}\n\nfunction getDurationFromConfig(\n config: CustomConfig,\n isLayoutTransition: boolean,\n animationName: AnimationNames\n): number {\n const defaultDuration = isLayoutTransition\n ? 0.3\n : Animations[animationName].duration;\n\n return config.durationV !== undefined\n ? config.durationV / 1000\n : defaultDuration;\n}\n\nfunction getCallbackFromConfig(config: CustomConfig): AnimationCallback {\n return config.callbackV !== undefined ? config.callbackV : null;\n}\n\nfunction getReversedFromConfig(config: CustomConfig) {\n return !!config.reversed;\n}\n\nexport function getProcessedConfig(\n animationName: string,\n animationType: LayoutAnimationType,\n config: CustomConfig,\n initialAnimationName: AnimationNames\n): AnimationConfig {\n return {\n animationName,\n animationType,\n duration: getDurationFromConfig(\n config,\n animationType === LayoutAnimationType.LAYOUT,\n initialAnimationName\n ),\n delay: getDelayFromConfig(config),\n easing: getEasingFromConfig(config),\n callback: getCallbackFromConfig(config),\n reversed: getReversedFromConfig(config),\n };\n}\n\nexport function saveSnapshot(element: HTMLElement) {\n const rect = element.getBoundingClientRect();\n\n const snapshot: ReanimatedSnapshot = {\n top: rect.top,\n left: rect.left,\n width: rect.width,\n height: rect.height,\n scrollOffsets: getElementScrollValue(element),\n };\n\n snapshots.set(element, snapshot);\n}\n\nexport function setElementAnimation(\n element: HTMLElement,\n animationConfig: AnimationConfig\n) {\n const { animationName, duration, delay, easing } = animationConfig;\n\n element.style.animationName = animationName;\n element.style.animationDuration = `${duration}s`;\n element.style.animationDelay = `${delay}s`;\n element.style.animationTimingFunction = easing;\n\n element.onanimationend = () => {\n animationConfig.callback?.(true);\n element.removeEventListener('animationcancel', animationCancelHandler);\n };\n\n const animationCancelHandler = () => {\n animationConfig.callback?.(false);\n element.removeEventListener('animationcancel', animationCancelHandler);\n };\n\n // Here we have to use `addEventListener` since element.onanimationcancel doesn't work on chrome\n element.onanimationstart = () => {\n if (animationConfig.animationType === LayoutAnimationType.ENTERING) {\n _updatePropsJS(\n { visibility: 'initial' },\n { _component: element as ReanimatedHTMLElement }\n );\n }\n\n element.addEventListener('animationcancel', animationCancelHandler);\n };\n\n if (!(animationName in Animations)) {\n scheduleAnimationCleanup(animationName, duration + delay);\n }\n}\n\nexport function handleLayoutTransition(\n element: HTMLElement,\n animationConfig: AnimationConfig,\n transitionData: TransitionData\n) {\n const { animationName } = animationConfig;\n\n let animationType;\n\n switch (animationName) {\n case 'LinearTransition':\n animationType = TransitionType.LINEAR;\n break;\n case 'SequencedTransition':\n animationType = TransitionType.SEQUENCED;\n break;\n case 'FadingTransition':\n animationType = TransitionType.FADING;\n break;\n default:\n animationType = TransitionType.LINEAR;\n break;\n }\n\n animationConfig.animationName = TransitionGenerator(\n animationType,\n transitionData\n );\n\n setElementAnimation(element, animationConfig);\n}\n\nfunction getElementScrollValue(element: HTMLElement): ScrollOffsets {\n let current: HTMLElement | null = element;\n\n const scrollOffsets: ScrollOffsets = {\n scrollTopOffset: 0,\n scrollLeftOffset: 0,\n };\n\n while (current) {\n if (current.scrollTop !== 0 && scrollOffsets.scrollTopOffset === 0) {\n scrollOffsets.scrollTopOffset = current.scrollTop;\n }\n\n if (current.scrollLeft !== 0 && scrollOffsets.scrollLeftOffset === 0) {\n scrollOffsets.scrollLeftOffset = current.scrollLeft;\n }\n\n current = current.parentElement;\n }\n\n return scrollOffsets;\n}\n\nexport function handleExitingAnimation(\n element: HTMLElement,\n animationConfig: AnimationConfig\n) {\n const parent = element.offsetParent;\n const dummy = element.cloneNode() as ReanimatedHTMLElement;\n dummy.reanimatedDummy = true;\n\n element.style.animationName = '';\n // We hide current element so only its copy with proper animation will be displayed\n element.style.visibility = 'hidden';\n\n // After cloning the element, we want to move all children from original element to its clone. This is because original element\n // will be unmounted, therefore when this code executes in child component, parent will be either empty or removed soon.\n // Using element.cloneNode(true) doesn't solve the problem, because it creates copy of children and we won't be able to set their animations\n //\n // This loop works because appendChild() moves element into its new parent instead of copying it\n while (element.firstChild) {\n dummy.appendChild(element.firstChild);\n }\n\n setElementAnimation(dummy, animationConfig);\n parent?.appendChild(dummy);\n\n const snapshot = snapshots.get(element)!;\n\n const scrollOffsets = getElementScrollValue(element);\n\n // Scroll does not trigger snapshotting, therefore if we start exiting animation after\n // scrolling through parent component, dummy will end up in wrong place. In order to fix that\n // we keep last known scroll position in snapshot and then adjust dummy position based on\n // last known scroll offset and current scroll offset\n\n const currentScrollTopOffset = scrollOffsets.scrollTopOffset;\n const lastScrollTopOffset = snapshot.scrollOffsets.scrollTopOffset;\n\n if (currentScrollTopOffset !== lastScrollTopOffset) {\n snapshot.top += lastScrollTopOffset - currentScrollTopOffset;\n }\n\n const currentScrollLeftOffset = scrollOffsets.scrollLeftOffset;\n const lastScrollLeftOffset = snapshot.scrollOffsets.scrollLeftOffset;\n\n if (currentScrollLeftOffset !== lastScrollLeftOffset) {\n snapshot.left += lastScrollLeftOffset - currentScrollLeftOffset;\n }\n\n snapshots.set(dummy, snapshot);\n\n setDummyPosition(dummy, snapshot);\n\n const originalOnAnimationEnd = dummy.onanimationend;\n\n dummy.onanimationend = function (event: AnimationEvent) {\n if (parent?.contains(dummy)) {\n dummy.removedAfterAnimation = true;\n parent.removeChild(dummy);\n }\n\n // Given that this function overrides onAnimationEnd, it won't be null\n originalOnAnimationEnd?.call(this, event);\n };\n\n dummy.addEventListener('animationcancel', () => {\n if (parent?.contains(dummy)) {\n dummy.removedAfterAnimation = true;\n parent.removeChild(dummy);\n }\n });\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,UAAU,EAAEC,cAAc,EAAEC,UAAU,QAAQ,UAAU;AASjE,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,wBAAwB,QAAQ,YAAY;AACrD,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,mBAAmB,QAAQ,iCAAiC;AAErE,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,kBAAkB;AAE9D,SAASC,mBAAmBA,CAACC,MAAoB,EAAU;EACzD,MAAMC,UAAU,GACdD,MAAM,CAACE,OAAO,IAAIF,MAAM,CAACE,OAAO,CAACC,IAAI,IAAIb,UAAU,GAC9CU,MAAM,CAACE,OAAO,CAACC,IAAI,GACpB,QAAQ;EAEd,OAAQ,gBAAeb,UAAU,CAACW,UAAU,CAAC,CAACG,QAAQ,CAAC,CAAE,GAAE;AAC7D;AAEA,SAASC,cAAcA,CAACC,QAAQ,GAAG,IAAI,EAAE;EACvC,OAAOC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,IAAIH,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI;AAC1D;AAEA,SAASI,kBAAkB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,CAAC;EAC3C,CAAC;EAEDX,KAAK,CAACf,gBAAgB,CAAC,iBAAiB,EAAE,MAAM;IAC9C,IAAIa,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEc,QAAQ,CAACZ,KAAK,CAAC,EAAE;MAC3BA,KAAK,CAACa,qBAAqB,GAAG,IAAI;MAClCf,MAAM,CAACgB,WAAW,CAACd,KAAK,CAAC;IAC3B;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["Animations","TransitionType","WebEasings","TransitionGenerator","scheduleAnimationCleanup","_updatePropsJS","ReduceMotion","isReducedMotion","LayoutAnimationType","setElementPosition","snapshots","Keyframe","getEasingFromConfig","config","easingName","easingV","name","toString","getRandomDelay","maxDelay","Math","floor","random","getDelayFromConfig","shouldRandomizeDelay","randomizeDelay","delay","delayV","getReducedMotionFromConfig","reduceMotionV","Never","Always","getDurationFromConfig","animationName","defaultDuration","duration","durationV","undefined","getCallbackFromConfig","callbackV","getReversedFromConfig","reversed","getProcessedConfig","animationType","easing","callback","maybeModifyStyleForKeyframe","element","style","animationFillMode","timestampRules","Object","values","definitions","position","saveSnapshot","rect","getBoundingClientRect","snapshot","top","left","width","height","scrollOffsets","getElementScrollValue","set","setElementAnimation","animationConfig","shouldSavePosition","configureAnimation","animationDuration","animationDelay","animationTimingFunction","ENTERING","requestAnimationFrame","onanimationend","_animationConfig$call","call","removeEventListener","animationCancelHandler","_animationConfig$call2","onanimationstart","visibility","addEventListener","get","handleLayoutTransition","transitionData","LINEAR","SEQUENCED","FADING","JUMPING","current","scrollTopOffset","scrollLeftOffset","scrollTop","scrollLeft","parentElement","handleExitingAnimation","parent","offsetParent","dummy","cloneNode","reanimatedDummy","firstChild","appendChild","currentScrollTopOffset","lastScrollTopOffset","currentScrollLeftOffset","lastScrollLeftOffset","originalOnAnimationEnd","event","contains","removedAfterAnimation","removeChild"],"sources":["componentUtils.ts"],"sourcesContent":["'use strict';\n\nimport { Animations, TransitionType } from './config';\nimport type {\n AnimationCallback,\n AnimationConfig,\n AnimationNames,\n CustomConfig,\n KeyframeDefinitions,\n} from './config';\nimport { WebEasings } from './Easing.web';\nimport type { WebEasingsNames } from './Easing.web';\nimport type { TransitionData } from './animationParser';\nimport { TransitionGenerator } from './createAnimation';\nimport { scheduleAnimationCleanup } from './domUtils';\nimport { _updatePropsJS } from '../../js-reanimated';\nimport type { ReanimatedHTMLElement } from '../../js-reanimated';\nimport { ReduceMotion } from '../../commonTypes';\nimport { isReducedMotion } from '../../PlatformChecker';\nimport { LayoutAnimationType } from '../animationBuilder/commonTypes';\nimport type { ReanimatedSnapshot, ScrollOffsets } from './componentStyle';\nimport { setElementPosition, snapshots } from './componentStyle';\nimport { Keyframe } from '../animationBuilder';\n\nfunction getEasingFromConfig(config: CustomConfig): string {\n const easingName =\n config.easingV && config.easingV.name in WebEasings\n ? (config.easingV.name as WebEasingsNames)\n : 'linear';\n\n return `cubic-bezier(${WebEasings[easingName].toString()})`;\n}\n\nfunction getRandomDelay(maxDelay = 1000) {\n return Math.floor(Math.random() * (maxDelay + 1)) / 1000;\n}\n\nfunction getDelayFromConfig(config: CustomConfig): number {\n const shouldRandomizeDelay = config.randomizeDelay;\n\n const delay = shouldRandomizeDelay ? getRandomDelay() : 0;\n\n if (!config.delayV) {\n return delay;\n }\n\n return shouldRandomizeDelay\n ? getRandomDelay(config.delayV)\n : config.delayV / 1000;\n}\n\nexport function getReducedMotionFromConfig(config: CustomConfig) {\n if (!config.reduceMotionV) {\n return isReducedMotion();\n }\n\n switch (config.reduceMotionV) {\n case ReduceMotion.Never:\n return false;\n case ReduceMotion.Always:\n return true;\n default:\n return isReducedMotion();\n }\n}\n\nfunction getDurationFromConfig(\n config: CustomConfig,\n animationName: string\n): number {\n // Duration in keyframe has to be in seconds. However, when using `.duration()` modifier we pass it in miliseconds.\n // If `duration` was specified in config, we have to divide it by `1000`, otherwise we return value that is already in seconds.\n\n const defaultDuration =\n animationName in Animations\n ? Animations[animationName as AnimationNames].duration\n : 0.3;\n\n return config.durationV !== undefined\n ? config.durationV / 1000\n : defaultDuration;\n}\n\nfunction getCallbackFromConfig(config: CustomConfig): AnimationCallback {\n return config.callbackV !== undefined ? config.callbackV : null;\n}\n\nfunction getReversedFromConfig(config: CustomConfig) {\n return !!config.reversed;\n}\n\nexport function getProcessedConfig(\n animationName: string,\n animationType: LayoutAnimationType,\n config: CustomConfig\n): AnimationConfig {\n return {\n animationName,\n animationType,\n duration: getDurationFromConfig(config, animationName),\n delay: getDelayFromConfig(config),\n easing: getEasingFromConfig(config),\n callback: getCallbackFromConfig(config),\n reversed: getReversedFromConfig(config),\n };\n}\n\nexport function maybeModifyStyleForKeyframe(\n element: HTMLElement,\n config: CustomConfig\n) {\n if (!(config instanceof Keyframe)) {\n return;\n }\n\n // We need to set `animationFillMode` to `forwards`, otherwise component will go back to its position.\n // This will result in wrong snapshot\n element.style.animationFillMode = 'forwards';\n\n for (const timestampRules of Object.values(\n config.definitions as KeyframeDefinitions\n )) {\n if ('originX' in timestampRules || 'originY' in timestampRules) {\n element.style.position = 'absolute';\n return;\n }\n }\n}\n\nexport function saveSnapshot(element: HTMLElement) {\n const rect = element.getBoundingClientRect();\n\n const snapshot: ReanimatedSnapshot = {\n top: rect.top,\n left: rect.left,\n width: rect.width,\n height: rect.height,\n scrollOffsets: getElementScrollValue(element),\n };\n\n snapshots.set(element, snapshot);\n}\n\nexport function setElementAnimation(\n element: HTMLElement,\n animationConfig: AnimationConfig,\n shouldSavePosition = false\n) {\n const { animationName, duration, delay, easing } = animationConfig;\n\n const configureAnimation = () => {\n element.style.animationName = animationName;\n element.style.animationDuration = `${duration}s`;\n element.style.animationDelay = `${delay}s`;\n element.style.animationTimingFunction = easing;\n };\n\n if (animationConfig.animationType === LayoutAnimationType.ENTERING) {\n // On chrome sometimes entering animations flicker. This is most likely caused by animation being interrupted\n // by already started tasks. To avoid flickering, we use `requestAnimationFrame`, which will run callback right before repaint.\n requestAnimationFrame(configureAnimation);\n } else {\n configureAnimation();\n }\n\n element.onanimationend = () => {\n if (shouldSavePosition) {\n saveSnapshot(element);\n }\n\n animationConfig.callback?.(true);\n element.removeEventListener('animationcancel', animationCancelHandler);\n };\n\n const animationCancelHandler = () => {\n animationConfig.callback?.(false);\n element.removeEventListener('animationcancel', animationCancelHandler);\n };\n\n // Here we have to use `addEventListener` since element.onanimationcancel doesn't work on chrome\n element.onanimationstart = () => {\n if (animationConfig.animationType === LayoutAnimationType.ENTERING) {\n _updatePropsJS(\n { visibility: 'initial' },\n element as ReanimatedHTMLElement\n );\n }\n\n element.addEventListener('animationcancel', animationCancelHandler);\n };\n\n if (!(animationName in Animations)) {\n scheduleAnimationCleanup(animationName, duration + delay, () => {\n if (shouldSavePosition) {\n setElementPosition(element, snapshots.get(element)!);\n }\n });\n }\n}\n\nexport function handleLayoutTransition(\n element: HTMLElement,\n animationConfig: AnimationConfig,\n transitionData: TransitionData\n) {\n const { animationName } = animationConfig;\n\n let animationType;\n\n switch (animationName) {\n case 'LinearTransition':\n animationType = TransitionType.LINEAR;\n break;\n case 'SequencedTransition':\n animationType = TransitionType.SEQUENCED;\n break;\n case 'FadingTransition':\n animationType = TransitionType.FADING;\n break;\n case 'JumpingTransition':\n animationType = TransitionType.JUMPING;\n break;\n default:\n animationType = TransitionType.LINEAR;\n break;\n }\n\n animationConfig.animationName = TransitionGenerator(\n animationType,\n transitionData\n );\n\n setElementAnimation(element, animationConfig);\n}\n\nfunction getElementScrollValue(element: HTMLElement): ScrollOffsets {\n let current: HTMLElement | null = element;\n\n const scrollOffsets: ScrollOffsets = {\n scrollTopOffset: 0,\n scrollLeftOffset: 0,\n };\n\n while (current) {\n if (current.scrollTop !== 0 && scrollOffsets.scrollTopOffset === 0) {\n scrollOffsets.scrollTopOffset = current.scrollTop;\n }\n\n if (current.scrollLeft !== 0 && scrollOffsets.scrollLeftOffset === 0) {\n scrollOffsets.scrollLeftOffset = current.scrollLeft;\n }\n\n current = current.parentElement;\n }\n\n return scrollOffsets;\n}\n\nexport function handleExitingAnimation(\n element: HTMLElement,\n animationConfig: AnimationConfig\n) {\n const parent = element.offsetParent;\n const dummy = element.cloneNode() as ReanimatedHTMLElement;\n dummy.reanimatedDummy = true;\n\n element.style.animationName = '';\n\n // After cloning the element, we want to move all children from original element to its clone. This is because original element\n // will be unmounted, therefore when this code executes in child component, parent will be either empty or removed soon.\n // Using element.cloneNode(true) doesn't solve the problem, because it creates copy of children and we won't be able to set their animations\n //\n // This loop works because appendChild() moves element into its new parent instead of copying it\n while (element.firstChild) {\n dummy.appendChild(element.firstChild);\n }\n\n setElementAnimation(dummy, animationConfig);\n parent?.appendChild(dummy);\n\n const snapshot = snapshots.get(element)!;\n\n const scrollOffsets = getElementScrollValue(element);\n\n // Scroll does not trigger snapshotting, therefore if we start exiting animation after\n // scrolling through parent component, dummy will end up in wrong place. In order to fix that\n // we keep last known scroll position in snapshot and then adjust dummy position based on\n // last known scroll offset and current scroll offset\n\n const currentScrollTopOffset = scrollOffsets.scrollTopOffset;\n const lastScrollTopOffset = snapshot.scrollOffsets.scrollTopOffset;\n\n if (currentScrollTopOffset !== lastScrollTopOffset) {\n snapshot.top += lastScrollTopOffset - currentScrollTopOffset;\n }\n\n const currentScrollLeftOffset = scrollOffsets.scrollLeftOffset;\n const lastScrollLeftOffset = snapshot.scrollOffsets.scrollLeftOffset;\n\n if (currentScrollLeftOffset !== lastScrollLeftOffset) {\n snapshot.left += lastScrollLeftOffset - currentScrollLeftOffset;\n }\n\n snapshots.set(dummy, snapshot);\n\n setElementPosition(dummy, snapshot);\n\n const originalOnAnimationEnd = dummy.onanimationend;\n\n dummy.onanimationend = function (event: AnimationEvent) {\n if (parent?.contains(dummy)) {\n dummy.removedAfterAnimation = true;\n parent.removeChild(dummy);\n }\n\n // Given that this function overrides onAnimationEnd, it won't be null\n originalOnAnimationEnd?.call(this, event);\n };\n\n dummy.addEventListener('animationcancel', () => {\n if (parent?.contains(dummy)) {\n dummy.removedAfterAnimation = true;\n parent.removeChild(dummy);\n }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9BjD,kBAAkB,CAAC2F,KAAK,EAAE1C,QAAQ,CAAC;EAEnC,MAAMmD,sBAAsB,GAAGT,KAAK,CAACzB,cAAc;EAEnDyB,KAAK,CAACzB,cAAc,GAAG,UAAUmC,KAAqB,EAAE;IACtD,IAAIZ,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEa,QAAQ,CAACX,KAAK,CAAC,EAAE;MAC3BA,KAAK,CAACY,qBAAqB,GAAG,IAAI;MAClCd,MAAM,CAACe,WAAW,CAACb,KAAK,CAAC;IAC3B;;IAEA;IACAS,sBAAsB,aAAtBA,sBAAsB,eAAtBA,sBAAsB,CAAEhC,IAAI,CAAC,IAAI,EAAEiC,KAAK,CAAC;EAC3C,CAAC;EAEDV,KAAK,CAACjB,gBAAgB,CAAC,iBAAiB,EAAE,MAAM;IAC9C,IAAIe,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEa,QAAQ,CAACX,KAAK,CAAC,EAAE;MAC3BA,KAAK,CAACY,qBAAqB,GAAG,IAAI;MAClCd,MAAM,CAACe,WAAW,CAACb,KAAK,CAAC;IAC3B;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -14,6 +14,7 @@ export let TransitionType = /*#__PURE__*/function (TransitionType) {
14
14
  TransitionType[TransitionType["LINEAR"] = 0] = "LINEAR";
15
15
  TransitionType[TransitionType["SEQUENCED"] = 1] = "SEQUENCED";
16
16
  TransitionType[TransitionType["FADING"] = 2] = "FADING";
17
+ TransitionType[TransitionType["JUMPING"] = 3] = "JUMPING";
17
18
  return TransitionType;
18
19
  }({});
19
20
  export const AnimationsData = {
@@ -58,16 +59,4 @@ export const Animations = {
58
59
  ...RollIn,
59
60
  ...RollOut
60
61
  };
61
-
62
- // Those are the easings that can be implemented using Bezier curves.
63
- // Others should be done as CSS animations
64
- export const WebEasings = {
65
- linear: [0, 0, 1, 1],
66
- ease: [0.42, 0, 1, 1],
67
- quad: [0.11, 0, 0.5, 0],
68
- cubic: [0.32, 0, 0.67, 0],
69
- sin: [0.12, 0, 0.39, 0],
70
- circle: [0.55, 0, 1, 0.45],
71
- exp: [0.7, 0, 0.84, 0]
72
- };
73
62
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BounceIn","BounceInData","BounceOut","BounceOutData","FadeIn","FadeInData","FadeOut","FadeOutData","FlipIn","FlipInData","FlipOut","FlipOutData","LightSpeedIn","LightSpeedInData","LightSpeedOut","LightSpeedOutData","Pinwheel","PinwheelData","RollIn","RollInData","RollOut","RollOutData","RotateIn","RotateInData","RotateOut","RotateOutData","SlideIn","SlideInData","SlideOut","SlideOutData","StretchIn","StretchInData","StretchOut","StretchOutData","ZoomIn","ZoomInData","ZoomOut","ZoomOutData","TransitionType","AnimationsData","Animations","WebEasings","linear","ease","quad","cubic","sin","circle","exp"],"sources":["config.ts"],"sourcesContent":["'use strict';\nimport type { ReduceMotion } from '../../commonTypes';\nimport type { LayoutAnimationType } from '../animationBuilder/commonTypes';\nimport {\n BounceIn,\n BounceInData,\n BounceOut,\n BounceOutData,\n} from './animation/Bounce.web';\nimport { FadeIn, FadeInData, FadeOut, FadeOutData } from './animation/Fade.web';\nimport { FlipIn, FlipInData, FlipOut, FlipOutData } from './animation/Flip.web';\nimport {\n LightSpeedIn,\n LightSpeedInData,\n LightSpeedOut,\n LightSpeedOutData,\n} from './animation/Lightspeed.web';\nimport { Pinwheel, PinwheelData } from './animation/Pinwheel.web';\nimport { RollIn, RollInData, RollOut, RollOutData } from './animation/Roll.web';\nimport {\n RotateIn,\n RotateInData,\n RotateOut,\n RotateOutData,\n} from './animation/Rotate.web';\nimport {\n SlideIn,\n SlideInData,\n SlideOut,\n SlideOutData,\n} from './animation/Slide.web';\nimport {\n StretchIn,\n StretchInData,\n StretchOut,\n StretchOutData,\n} from './animation/Stretch.web';\nimport { ZoomIn, ZoomInData, ZoomOut, ZoomOutData } from './animation/Zoom.web';\n\nimport type { AnimationData } from './animationParser';\n\nexport type AnimationCallback = ((finished: boolean) => void) | null;\n\nexport interface AnimationConfig {\n animationName: string;\n animationType: LayoutAnimationType;\n duration: number;\n delay: number;\n easing: string;\n callback: AnimationCallback;\n reversed: boolean;\n}\n\nexport interface CustomConfig {\n easingV?: () => number;\n durationV?: number;\n delayV?: number;\n randomizeDelay?: boolean;\n reduceMotionV?: ReduceMotion;\n callbackV?: AnimationCallback;\n reversed?: boolean;\n}\n\nexport enum TransitionType {\n LINEAR,\n SEQUENCED,\n FADING,\n}\n\nexport const AnimationsData: Record<string, AnimationData> = {\n ...FadeInData,\n ...FadeOutData,\n ...BounceInData,\n ...BounceOutData,\n ...FlipInData,\n ...FlipOutData,\n ...StretchInData,\n ...StretchOutData,\n ...ZoomInData,\n ...ZoomOutData,\n ...SlideInData,\n ...SlideOutData,\n ...LightSpeedInData,\n ...LightSpeedOutData,\n ...PinwheelData,\n ...RotateInData,\n ...RotateOutData,\n ...RollInData,\n ...RollOutData,\n};\n\nexport const Animations = {\n ...FadeIn,\n ...FadeOut,\n ...BounceIn,\n ...BounceOut,\n ...FlipIn,\n ...FlipOut,\n ...StretchIn,\n ...StretchOut,\n ...ZoomIn,\n ...ZoomOut,\n ...SlideIn,\n ...SlideOut,\n ...LightSpeedIn,\n ...LightSpeedOut,\n ...Pinwheel,\n ...RotateIn,\n ...RotateOut,\n ...RollIn,\n ...RollOut,\n};\n\n// Those are the easings that can be implemented using Bezier curves.\n// Others should be done as CSS animations\nexport const WebEasings = {\n linear: [0, 0, 1, 1],\n ease: [0.42, 0, 1, 1],\n quad: [0.11, 0, 0.5, 0],\n cubic: [0.32, 0, 0.67, 0],\n sin: [0.12, 0, 0.39, 0],\n circle: [0.55, 0, 1, 0.45],\n exp: [0.7, 0, 0.84, 0],\n};\n\nexport type AnimationNames = keyof typeof Animations;\nexport type LayoutTransitionsNames = keyof typeof AnimationsData;\nexport type WebEasingsNames = keyof typeof WebEasings;\n"],"mappings":"AAAA,YAAY;;AAGZ,SACEA,QAAQ,EACRC,YAAY,EACZC,SAAS,EACTC,a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MAAM;EACT,GAAGE,OAAO;EACV,GAAGN,QAAQ;EACX,GAAGE,SAAS;EACZ,GAAGM,MAAM;EACT,GAAGE,OAAO;EACV,GAAGoB,SAAS;EACZ,GAAGE,UAAU;EACb,GAAGE,MAAM;EACT,GAAGE,OAAO;EACV,GAAGV,OAAO;EACV,GAAGE,QAAQ;EACX,GAAGhB,YAAY;EACf,GAAGE,aAAa;EAChB,GAAGE,QAAQ;EACX,GAAGM,QAAQ;EACX,GAAGE,SAAS;EACZ,GAAGN,MAAM;EACT,GAAGE;AACL,CAAC;;AAED;AACA;AACA,OAAO,MAAMqB,UAAU,GAAG;EACxBC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACpBC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACrBC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;EACvBC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;EACzBC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;EACvBC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;EAC1BC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["BounceIn","BounceInData","BounceOut","BounceOutData","FadeIn","FadeInData","FadeOut","FadeOutData","FlipIn","FlipInData","FlipOut","FlipOutData","LightSpeedIn","LightSpeedInData","LightSpeedOut","LightSpeedOutData","Pinwheel","PinwheelData","RollIn","RollInData","RollOut","RollOutData","RotateIn","RotateInData","RotateOut","RotateOutData","SlideIn","SlideInData","SlideOut","SlideOutData","StretchIn","StretchInData","StretchOut","StretchOutData","ZoomIn","ZoomInData","ZoomOut","ZoomOutData","TransitionType","AnimationsData","Animations"],"sources":["config.ts"],"sourcesContent":["'use strict';\nimport type { ReduceMotion } from '../../commonTypes';\nimport type { LayoutAnimationType } from '../animationBuilder/commonTypes';\nimport {\n BounceIn,\n BounceInData,\n BounceOut,\n BounceOutData,\n} from './animation/Bounce.web';\nimport { FadeIn, FadeInData, FadeOut, FadeOutData } from './animation/Fade.web';\nimport { FlipIn, FlipInData, FlipOut, FlipOutData } from './animation/Flip.web';\nimport {\n LightSpeedIn,\n LightSpeedInData,\n LightSpeedOut,\n LightSpeedOutData,\n} from './animation/Lightspeed.web';\nimport { Pinwheel, PinwheelData } from './animation/Pinwheel.web';\nimport { RollIn, RollInData, RollOut, RollOutData } from './animation/Roll.web';\nimport {\n RotateIn,\n RotateInData,\n RotateOut,\n RotateOutData,\n} from './animation/Rotate.web';\nimport {\n SlideIn,\n SlideInData,\n SlideOut,\n SlideOutData,\n} from './animation/Slide.web';\nimport {\n StretchIn,\n StretchInData,\n StretchOut,\n StretchOutData,\n} from './animation/Stretch.web';\nimport { ZoomIn, ZoomInData, ZoomOut, ZoomOutData } from './animation/Zoom.web';\n\nimport type { AnimationData, AnimationStyle } from './animationParser';\n\nexport type AnimationCallback = ((finished: boolean) => void) | null;\n\nexport type KeyframeDefinitions = Record<number, AnimationStyle>;\n\nexport interface AnimationConfig {\n animationName: string;\n animationType: LayoutAnimationType;\n duration: number;\n delay: number;\n easing: string;\n callback: AnimationCallback;\n reversed: boolean;\n}\n\nexport interface CustomConfig {\n easingV?: () => number;\n durationV?: number;\n delayV?: number;\n randomizeDelay?: boolean;\n reduceMotionV?: ReduceMotion;\n callbackV?: AnimationCallback;\n reversed?: boolean;\n definitions?: KeyframeDefinitions;\n}\n\nexport enum TransitionType {\n LINEAR,\n SEQUENCED,\n FADING,\n JUMPING,\n}\n\nexport const AnimationsData: Record<string, AnimationData> = {\n ...FadeInData,\n ...FadeOutData,\n ...BounceInData,\n ...BounceOutData,\n ...FlipInData,\n ...FlipOutData,\n ...StretchInData,\n ...StretchOutData,\n ...ZoomInData,\n ...ZoomOutData,\n ...SlideInData,\n ...SlideOutData,\n ...LightSpeedInData,\n ...LightSpeedOutData,\n ...PinwheelData,\n ...RotateInData,\n ...RotateOutData,\n ...RollInData,\n ...RollOutData,\n};\n\nexport const Animations = {\n ...FadeIn,\n ...FadeOut,\n ...BounceIn,\n ...BounceOut,\n ...FlipIn,\n ...FlipOut,\n ...StretchIn,\n ...StretchOut,\n ...ZoomIn,\n ...ZoomOut,\n ...SlideIn,\n ...SlideOut,\n ...LightSpeedIn,\n ...LightSpeedOut,\n ...Pinwheel,\n ...RotateIn,\n ...RotateOut,\n ...RollIn,\n ...RollOut,\n};\n\nexport type AnimationNames = keyof typeof Animations;\nexport type LayoutTransitionsNames = keyof typeof AnimationsData;\n"],"mappings":"AAAA,YAAY;;AAGZ,SACEA,QAAQ,EACRC,YAAY,EACZC,SAAS,EACTC,aAAa,QACR,wBAAwB;AAC/B,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,WAAW,QAAQ,sBAAsB;AAC/E,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,WAAW,QAAQ,sBAAsB;AAC/E,SACEC,YAAY,EACZC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,QACZ,4BAA4B;AACnC,SAASC,QAAQ,EAAEC,YAAY,QAAQ,0BAA0B;AACjE,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,WAAW,QAAQ,sBAAsB;AAC/E,SACEC,QAAQ,EACRC,YAAY,EACZC,SAAS,EACTC,aAAa,QACR,wBAAwB;AAC/B,SACEC,OAAO,EACPC,WAAW,EACXC,QAAQ,EACRC,YAAY,QACP,uBAAuB;AAC9B,SACEC,SAAS,EACTC,aAAa,EACbC,UAAU,EACVC,cAAc,QACT,yBAAyB;AAChC,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,WAAW,QAAQ,sBAAsB;AA6B/E,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAO1B,OAAO,MAAMC,cAA6C,GAAG;EAC3D,GAAGlC,UAAU;EACb,GAAGE,WAAW;EACd,GAAGN,YAAY;EACf,GAAGE,aAAa;EAChB,GAAGM,UAAU;EACb,GAAGE,WAAW;EACd,GAAGoB,aAAa;EAChB,GAAGE,cAAc;EACjB,GAAGE,UAAU;EACb,GAAGE,WAAW;EACd,GAAGV,WAAW;EACd,GAAGE,YAAY;EACf,GAAGhB,gBAAgB;EACnB,GAAGE,iBAAiB;EACpB,GAAGE,YAAY;EACf,GAAGM,YAAY;EACf,GAAGE,aAAa;EAChB,GAAGN,UAAU;EACb,GAAGE;AACL,CAAC;AAED,OAAO,MAAMmB,UAAU,GAAG;EACxB,GAAGpC,MAAM;EACT,GAAGE,OAAO;EACV,GAAGN,QAAQ;EACX,GAAGE,SAAS;EACZ,GAAGM,MAAM;EACT,GAAGE,OAAO;EACV,GAAGoB,SAAS;EACZ,GAAGE,UAAU;EACb,GAAGE,MAAM;EACT,GAAGE,OAAO;EACV,GAAGV,OAAO;EACV,GAAGE,QAAQ;EACX,GAAGhB,YAAY;EACf,GAAGE,aAAa;EAChB,GAAGE,QAAQ;EACX,GAAGM,QAAQ;EACX,GAAGE,SAAS;EACZ,GAAGN,MAAM;EACT,GAAGE;AACL,CAAC","ignoreList":[]}
@@ -5,8 +5,8 @@ import { convertAnimationObjectToKeyframes } from './animationParser';
5
5
  import { LinearTransition } from './transition/Linear.web';
6
6
  import { SequencedTransition } from './transition/Sequenced.web';
7
7
  import { FadingTransition } from './transition/Fading.web';
8
+ import { JumpingTransition } from './transition/Jumping.web';
8
9
  import { insertWebAnimation } from './domUtils';
9
-
10
10
  // Translate values are passed as numbers. However, if `translate` property receives number, it will not automatically
11
11
  // convert it to `px`. Therefore if we want to keep transform we have to add 'px' suffix to each of translate values
12
12
  // that are present inside transform.
@@ -18,7 +18,7 @@ function addPxToTranslate(transform) {
18
18
  const newTransform = transform.map(transformProp => {
19
19
  const newTransformProp = {};
20
20
  for (const [key, value] of Object.entries(transformProp)) {
21
- if (key.includes('translate')) {
21
+ if (key.includes('translate') && typeof value === 'number') {
22
22
  // @ts-ignore After many trials we decided to ignore this error - it says that we cannot use 'key' to index this object.
23
23
  // Sadly it doesn't go away after using cast `key as keyof TransformProperties`.
24
24
  newTransformProp[key] = `${value}px`;
@@ -31,6 +31,22 @@ function addPxToTranslate(transform) {
31
31
  });
32
32
  return newTransform;
33
33
  }
34
+ export function createCustomKeyFrameAnimation(keyframeDefinitions) {
35
+ for (const value of Object.values(keyframeDefinitions)) {
36
+ if (value.transform) {
37
+ value.transform = addPxToTranslate(value.transform);
38
+ }
39
+ }
40
+ const animationData = {
41
+ name: '',
42
+ style: keyframeDefinitions,
43
+ duration: -1
44
+ };
45
+ animationData.name = generateNextCustomKeyframeName();
46
+ const parsedKeyframe = convertAnimationObjectToKeyframes(animationData);
47
+ insertWebAnimation(animationData.name, parsedKeyframe);
48
+ return animationData.name;
49
+ }
34
50
  let customKeyframeCounter = 0;
35
51
  function generateNextCustomKeyframeName() {
36
52
  return `REA${customKeyframeCounter++}`;
@@ -56,6 +72,9 @@ export function TransitionGenerator(transitionType, transitionData) {
56
72
  case TransitionType.FADING:
57
73
  transitionObject = FadingTransition(transitionKeyframeName, transitionData);
58
74
  break;
75
+ case TransitionType.JUMPING:
76
+ transitionObject = JumpingTransition(transitionKeyframeName, transitionData);
77
+ break;
59
78
  }
60
79
  const transitionKeyframe = convertAnimationObjectToKeyframes(transitionObject);
61
80
  insertWebAnimation(transitionKeyframeName, transitionKeyframe);
@@ -1 +1 @@
1
- {"version":3,"names":["TransitionType","convertAnimationObjectToKeyframes","LinearTransition","SequencedTransition","FadingTransition","insertWebAnimation","addPxToTranslate","transform","newTransform","map","transformProp","newTransformProp","key","value","Object","entries","includes","customKeyframeCounter","generateNextCustomKeyframeName","TransitionGenerator","transitionType","transitionData","transitionKeyframeName","transitionObject","LINEAR","SEQUENCED","FADING","transitionKeyframe"],"sources":["createAnimation.ts"],"sourcesContent":["'use strict';\n\nimport { TransitionType } from './config';\nimport { convertAnimationObjectToKeyframes } from './animationParser';\nimport type {\n ReanimatedWebTransformProperties,\n TransitionData,\n} from './animationParser';\nimport type { TransformsStyle } from 'react-native';\nimport { LinearTransition } from './transition/Linear.web';\nimport { SequencedTransition } from './transition/Sequenced.web';\nimport { FadingTransition } from './transition/Fading.web';\nimport { insertWebAnimation } from './domUtils';\n\n// Translate values are passed as numbers. However, if `translate` property receives number, it will not automatically\n// convert it to `px`. Therefore if we want to keep transform we have to add 'px' suffix to each of translate values\n// that are present inside transform.\n//\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction addPxToTranslate(\n transform: NonNullable<TransformsStyle['transform']>\n) {\n type RNTransformProp = (typeof transform)[number];\n\n // @ts-ignore `existingTransform` cannot be string because in that case\n // we throw error in `extractTransformFromStyle`\n const newTransform = transform.map((transformProp: RNTransformProp) => {\n const newTransformProp: ReanimatedWebTransformProperties = {};\n for (const [key, value] of Object.entries(transformProp)) {\n if (key.includes('translate')) {\n // @ts-ignore After many trials we decided to ignore this error - it says that we cannot use 'key' to index this object.\n // Sadly it doesn't go away after using cast `key as keyof TransformProperties`.\n newTransformProp[key] = `${value}px`;\n } else {\n // @ts-ignore same as above.\n newTransformProp[key] = value;\n }\n }\n return newTransformProp;\n });\n\n return newTransform;\n}\n\nlet customKeyframeCounter = 0;\n\nfunction generateNextCustomKeyframeName() {\n return `REA${customKeyframeCounter++}`;\n}\n\n/**\n * Creates transition of given type, appends it to stylesheet and returns keyframe name.\n *\n * @param transitionType - Type of transition (e.g. LINEAR).\n * @param transitionData - Object containing data for transforms (translateX, scaleX,...).\n * @returns Keyframe name that represents transition.\n */\nexport function TransitionGenerator(\n transitionType: TransitionType,\n transitionData: TransitionData\n) {\n const transitionKeyframeName = generateNextCustomKeyframeName();\n let transitionObject;\n\n switch (transitionType) {\n case TransitionType.LINEAR:\n transitionObject = LinearTransition(\n transitionKeyframeName,\n transitionData\n );\n break;\n case TransitionType.SEQUENCED:\n transitionObject = SequencedTransition(\n transitionKeyframeName,\n transitionData\n );\n break;\n case TransitionType.FADING:\n transitionObject = FadingTransition(\n transitionKeyframeName,\n transitionData\n );\n break;\n }\n\n const transitionKeyframe =\n convertAnimationObjectToKeyframes(transitionObject);\n\n insertWebAnimation(transitionKeyframeName, transitionKeyframe);\n\n return transitionKeyframeName;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,cAAc,QAAQ,UAAU;AACzC,SAASC,iCAAiC,QAAQ,mBAAmB;AAMrE,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,kBAAkB,QAAQ,YAAY;;AAE/C;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACvBC,SAAoD,EACpD;EAGA;EACA;EACA,MAAMC,YAAY,GAAGD,SAAS,CAACE,GAAG,CAAEC,aAA8B,IAAK;IACrE,MAAMC,gBAAkD,GAAG,CAAC,CAAC;IAC7D,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,aAAa,CAAC,EAAE;MACxD,IAAIE,GAAG,CAACI,QAAQ,CAAC,WAAW,CAAC,EAAE;QAC7B;QACA;QACAL,gBAAgB,CAACC,GAAG,CAAC,GAAI,GAAEC,KAAM,IAAG;MACtC,CAAC,MAAM;QACL;QACAF,gBAAgB,CAACC,GAAG,CAAC,GAAGC,KAAK;MAC/B;IACF;IACA,OAAOF,gBAAgB;EACzB,CAAC,CAAC;EAEF,OAAOH,YAAY;AACrB;AAEA,IAAIS,qBAAqB,GAAG,CAAC;AAE7B,SAASC,8BAA8BA,CAAA,EAAG;EACxC,OAAQ,MAAKD,qBAAqB,EAAG,EAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,mBAAmBA,CACjCC,cAA8B,EAC9BC,cAA8B,EAC9B;EACA,MAAMC,sBAAsB,GAAGJ,8BAA8B,CAAC,CAAC;EAC/D,IAAIK,gBAAgB;EAEpB,QAAQH,cAAc;IACpB,KAAKpB,cAAc,CAACwB,MAAM;MACxBD,gBAAgB,GAAGrB,gBAAgB,CACjCoB,sBAAsB,EACtBD,cACF,CAAC;MACD;IACF,KAAKrB,cAAc,CAACyB,SAAS;MAC3BF,gBAAgB,GAAGpB,mBAAmB,CACpCmB,sBAAsB,EACtBD,cACF,CAAC;MACD;IACF,KAAKrB,cAAc,CAAC0B,MAAM;MACxBH,gBAAgB,GAAGnB,gBAAgB,CACjCkB,sBAAsB,EACtBD,cACF,CAAC;MACD;EACJ;EAEA,MAAMM,kBAAkB,GACtB1B,iCAAiC,CAACsB,gBAAgB,CAAC;EAErDlB,kBAAkB,CAACiB,sBAAsB,EAAEK,kBAAkB,CAAC;EAE9D,OAAOL,sBAAsB;AAC/B","ignoreList":[]}
1
+ {"version":3,"names":["TransitionType","convertAnimationObjectToKeyframes","LinearTransition","SequencedTransition","FadingTransition","JumpingTransition","insertWebAnimation","addPxToTranslate","transform","newTransform","map","transformProp","newTransformProp","key","value","Object","entries","includes","createCustomKeyFrameAnimation","keyframeDefinitions","values","animationData","name","style","duration","generateNextCustomKeyframeName","parsedKeyframe","customKeyframeCounter","TransitionGenerator","transitionType","transitionData","transitionKeyframeName","transitionObject","LINEAR","SEQUENCED","FADING","JUMPING","transitionKeyframe"],"sources":["createAnimation.ts"],"sourcesContent":["'use strict';\n\nimport { TransitionType } from './config';\nimport type { KeyframeDefinitions } from './config';\nimport { convertAnimationObjectToKeyframes } from './animationParser';\nimport type {\n AnimationData,\n ReanimatedWebTransformProperties,\n TransitionData,\n} from './animationParser';\nimport type { TransformsStyle } from 'react-native';\nimport { LinearTransition } from './transition/Linear.web';\nimport { SequencedTransition } from './transition/Sequenced.web';\nimport { FadingTransition } from './transition/Fading.web';\nimport { JumpingTransition } from './transition/Jumping.web';\nimport { insertWebAnimation } from './domUtils';\n\ntype TransformType = NonNullable<TransformsStyle['transform']>;\n\n// Translate values are passed as numbers. However, if `translate` property receives number, it will not automatically\n// convert it to `px`. Therefore if we want to keep transform we have to add 'px' suffix to each of translate values\n// that are present inside transform.\n//\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction addPxToTranslate(transform: TransformType) {\n type RNTransformProp = (typeof transform)[number];\n\n // @ts-ignore `existingTransform` cannot be string because in that case\n // we throw error in `extractTransformFromStyle`\n const newTransform = transform.map((transformProp: RNTransformProp) => {\n const newTransformProp: ReanimatedWebTransformProperties = {};\n for (const [key, value] of Object.entries(transformProp)) {\n if (key.includes('translate') && typeof value === 'number') {\n // @ts-ignore After many trials we decided to ignore this error - it says that we cannot use 'key' to index this object.\n // Sadly it doesn't go away after using cast `key as keyof TransformProperties`.\n newTransformProp[key] = `${value}px`;\n } else {\n // @ts-ignore same as above.\n newTransformProp[key] = value;\n }\n }\n return newTransformProp;\n });\n\n return newTransform;\n}\n\nexport function createCustomKeyFrameAnimation(\n keyframeDefinitions: KeyframeDefinitions\n) {\n for (const value of Object.values(keyframeDefinitions)) {\n if (value.transform) {\n value.transform = addPxToTranslate(value.transform as TransformType);\n }\n }\n\n const animationData: AnimationData = {\n name: '',\n style: keyframeDefinitions,\n duration: -1,\n };\n\n animationData.name = generateNextCustomKeyframeName();\n\n const parsedKeyframe = convertAnimationObjectToKeyframes(animationData);\n\n insertWebAnimation(animationData.name, parsedKeyframe);\n\n return animationData.name;\n}\n\nlet customKeyframeCounter = 0;\n\nfunction generateNextCustomKeyframeName() {\n return `REA${customKeyframeCounter++}`;\n}\n\n/**\n * Creates transition of given type, appends it to stylesheet and returns keyframe name.\n *\n * @param transitionType - Type of transition (e.g. LINEAR).\n * @param transitionData - Object containing data for transforms (translateX, scaleX,...).\n * @returns Keyframe name that represents transition.\n */\nexport function TransitionGenerator(\n transitionType: TransitionType,\n transitionData: TransitionData\n) {\n const transitionKeyframeName = generateNextCustomKeyframeName();\n let transitionObject;\n\n switch (transitionType) {\n case TransitionType.LINEAR:\n transitionObject = LinearTransition(\n transitionKeyframeName,\n transitionData\n );\n break;\n case TransitionType.SEQUENCED:\n transitionObject = SequencedTransition(\n transitionKeyframeName,\n transitionData\n );\n break;\n case TransitionType.FADING:\n transitionObject = FadingTransition(\n transitionKeyframeName,\n transitionData\n );\n break;\n\n case TransitionType.JUMPING:\n transitionObject = JumpingTransition(\n transitionKeyframeName,\n transitionData\n );\n break;\n }\n\n const transitionKeyframe =\n convertAnimationObjectToKeyframes(transitionObject);\n\n insertWebAnimation(transitionKeyframeName, transitionKeyframe);\n\n return transitionKeyframeName;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,cAAc,QAAQ,UAAU;AAEzC,SAASC,iCAAiC,QAAQ,mBAAmB;AAOrE,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,kBAAkB,QAAQ,YAAY;AAI/C;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAACC,SAAwB,EAAE;EAGlD;EACA;EACA,MAAMC,YAAY,GAAGD,SAAS,CAACE,GAAG,CAAEC,aAA8B,IAAK;IACrE,MAAMC,gBAAkD,GAAG,CAAC,CAAC;IAC7D,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,aAAa,CAAC,EAAE;MACxD,IAAIE,GAAG,CAACI,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAOH,KAAK,KAAK,QAAQ,EAAE;QAC1D;QACA;QACAF,gBAAgB,CAACC,GAAG,CA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,sBAAsB,EACtBD,cACF,CAAC;MACD;IACF,KAAK9B,cAAc,CAACmC,MAAM;MACxBH,gBAAgB,GAAG5B,gBAAgB,CACjC2B,sBAAsB,EACtBD,cACF,CAAC;MACD;IAEF,KAAK9B,cAAc,CAACoC,OAAO;MACzBJ,gBAAgB,GAAG3B,iBAAiB,CAClC0B,sBAAsB,EACtBD,cACF,CAAC;MACD;EACJ;EAEA,MAAMO,kBAAkB,GACtBpC,iCAAiC,CAAC+B,gBAAgB,CAAC;EAErD1B,kBAAkB,CAACyB,sBAAsB,EAAEM,kBAAkB,CAAC;EAE9D,OAAON,sBAAsB;AAC/B","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  import { isWindowAvailable } from '../../PlatformChecker';
4
- import { setDummyPosition, snapshots } from './componentStyle';
4
+ import { setElementPosition, snapshots } from './componentStyle';
5
5
  import { Animations } from './config';
6
6
  const PREDEFINED_WEB_ANIMATIONS_ID = 'ReanimatedPredefinedWebAnimationsStyle';
7
7
  const CUSTOM_WEB_ANIMATIONS_ID = 'ReanimatedCustomWebAnimationsStyle';
@@ -59,7 +59,7 @@ export function insertWebAnimation(animationName, keyframe) {
59
59
  animationNameToIndex.set(animationNameList[i], nextAnimationIndex + 1);
60
60
  }
61
61
  }
62
- function removeWebAnimation(animationName) {
62
+ function removeWebAnimation(animationName, animationRemoveCallback) {
63
63
  var _styleTag$sheet;
64
64
  // Without this check SSR crashes because document is undefined (NextExample on CI)
65
65
  if (!isWindowAvailable()) {
@@ -70,6 +70,7 @@ function removeWebAnimation(animationName) {
70
70
  if (currentAnimationIndex === undefined) {
71
71
  throw new Error('[Reanimated] Failed to obtain animation index.');
72
72
  }
73
+ animationRemoveCallback();
73
74
  (_styleTag$sheet = styleTag.sheet) === null || _styleTag$sheet === void 0 || _styleTag$sheet.deleteRule(currentAnimationIndex);
74
75
  animationNameList.splice(currentAnimationIndex, 1);
75
76
  animationNameToIndex.delete(animationName);
@@ -85,11 +86,11 @@ function removeWebAnimation(animationName) {
85
86
  const timeoutScale = 1.25; // We use this value to enlarge timeout duration. It can prove useful if animation lags.
86
87
  const frameDurationMs = 16; // Just an approximation.
87
88
  const minimumFrames = 10;
88
- export function scheduleAnimationCleanup(animationName, animationDuration) {
89
+ export function scheduleAnimationCleanup(animationName, animationDuration, animationRemoveCallback) {
89
90
  // If duration is very short, we want to keep remove delay to at least 10 frames
90
91
  // In our case it is exactly 160/1099 s, which is approximately 0.15s
91
92
  const timeoutValue = Math.max(animationDuration * timeoutScale * 1000, animationDuration + frameDurationMs * minimumFrames);
92
- setTimeout(() => removeWebAnimation(animationName), timeoutValue);
93
+ setTimeout(() => removeWebAnimation(animationName, animationRemoveCallback), timeoutValue);
93
94
  }
94
95
  function reattachElementToAncestor(child, parent) {
95
96
  const childSnapshot = snapshots.get(child);
@@ -101,7 +102,7 @@ function reattachElementToAncestor(child, parent) {
101
102
  // We use that so we don't end up in infinite loop
102
103
  child.removedAfterAnimation = true;
103
104
  parent.appendChild(child);
104
- setDummyPosition(child, childSnapshot);
105
+ setElementPosition(child, childSnapshot);
105
106
  const originalOnAnimationEnd = child.onanimationend;
106
107
  child.onanimationend = function (event) {
107
108
  parent.removeChild(child);