'use strict'; import type { IEntryExitAnimationBuilder, EntryExitAnimationFunction, } from '../animationBuilder/commonTypes'; import type { BaseAnimationBuilder } from '../animationBuilder'; import { ComplexAnimationBuilder } from '../animationBuilder'; /** * Stretch animation on the X axis. You can modify the behavior by chaining methods like `.springify()` or `.duration(500)`. * * You pass it to the `entering` prop on [an Animated component](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animated-component). * * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/entering-exiting-animations/#stretch */ export class StretchInX extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static presetName = 'StretchInX'; static createInstance( this: T ): InstanceType { return new StretchInX() as InstanceType; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return () => { 'worklet'; return { animations: { transform: [{ scaleX: delayFunction(delay, animation(1, config)) }], }, initialValues: { transform: [{ scaleX: 0 }], ...initialValues, }, callback, }; }; }; } /** * Stretch animation on the Y axis. You can modify the behavior by chaining methods like `.springify()` or `.duration(500)`. * * You pass it to the `entering` prop on [an Animated component](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animated-component). * * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/entering-exiting-animations/#stretch */ export class StretchInY extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static presetName = 'StretchInY'; static createInstance( this: T ): InstanceType { return new StretchInY() as InstanceType; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return () => { 'worklet'; return { animations: { transform: [{ scaleY: delayFunction(delay, animation(1, config)) }], }, initialValues: { transform: [{ scaleY: 0 }], ...initialValues, }, callback, }; }; }; } /** * Stretch animation on the X axis. You can modify the behavior by chaining methods like `.springify()` or `.duration(500)`. * * You pass it to the `exiting` prop on [an Animated component](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animated-component). * * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/entering-exiting-animations/#stretch */ export class StretchOutX extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static presetName = 'StretchOutX'; static createInstance( this: T ): InstanceType { return new StretchOutX() as InstanceType; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return () => { 'worklet'; return { animations: { transform: [{ scaleX: delayFunction(delay, animation(0, config)) }], }, initialValues: { transform: [{ scaleX: 1 }], ...initialValues, }, callback, }; }; }; } /** * Stretch animation on the Y axis. You can modify the behavior by chaining methods like `.springify()` or `.duration(500)`. * * You pass it to the `exiting` prop on [an Animated component](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animated-component). * * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/entering-exiting-animations/#stretch */ export class StretchOutY extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static presetName = 'StretchOutY'; static createInstance( this: T ): InstanceType { return new StretchOutY() as InstanceType; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return () => { 'worklet'; return { animations: { transform: [{ scaleY: delayFunction(delay, animation(0, config)) }], }, initialValues: { transform: [{ scaleY: 1 }], ...initialValues, }, callback, }; }; }; }