UNPKG

react-native-reanimated

Version:

More powerful alternative to Animated library for React Native.

166 lines (153 loc) 4.59 kB
'use strict'; import type { BaseAnimationBuilder } from '../animationBuilder'; import { ComplexAnimationBuilder } from '../animationBuilder'; import type { EntryExitAnimationsValues, EntryExitAnimationFunction, IEntryExitAnimationBuilder, } from '../animationBuilder/commonTypes'; export class RollInLeft extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static createInstance<T extends typeof BaseAnimationBuilder>( this: T ): InstanceType<T> { return new RollInLeft() as InstanceType<T>; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return (values: EntryExitAnimationsValues) => { 'worklet'; return { animations: { transform: [ { translateX: delayFunction(delay, animation(0), config) }, { rotate: delayFunction(delay, animation('0deg', config)) }, ], }, initialValues: { transform: [ { translateX: -values.windowWidth }, { rotate: '-180deg' }, ], ...initialValues, }, callback: callback, }; }; }; } export class RollInRight extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static createInstance<T extends typeof BaseAnimationBuilder>( this: T ): InstanceType<T> { return new RollInRight() as InstanceType<T>; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return (values: EntryExitAnimationsValues) => { 'worklet'; return { animations: { transform: [ { translateX: delayFunction(delay, animation(0, config)) }, { rotate: delayFunction(delay, animation('0deg', config)) }, ], }, initialValues: { transform: [{ translateX: values.windowWidth }, { rotate: '180deg' }], ...initialValues, }, callback: callback, }; }; }; } export class RollOutLeft extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static createInstance<T extends typeof BaseAnimationBuilder>( this: T ): InstanceType<T> { return new RollOutLeft() as InstanceType<T>; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return (values: EntryExitAnimationsValues) => { 'worklet'; return { animations: { transform: [ { translateX: delayFunction( delay, animation(-values.windowWidth, config) ), }, { rotate: delayFunction(delay, animation('-180deg', config)) }, ], }, initialValues: { transform: [{ translateX: 0 }, { rotate: '0deg' }], ...initialValues, }, callback: callback, }; }; }; } export class RollOutRight extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder { static createInstance<T extends typeof BaseAnimationBuilder>( this: T ): InstanceType<T> { return new RollOutRight() as InstanceType<T>; } build = (): EntryExitAnimationFunction => { const delayFunction = this.getDelayFunction(); const [animation, config] = this.getAnimationAndConfig(); const delay = this.getDelay(); const callback = this.callbackV; const initialValues = this.initialValues; return (values: EntryExitAnimationsValues) => { 'worklet'; return { animations: { transform: [ { translateX: delayFunction( delay, animation(values.windowWidth, config) ), }, { rotate: delayFunction(delay, animation('180deg', config)) }, ], }, initialValues: { transform: [{ translateX: 0 }, { rotate: '0deg' }], ...initialValues, }, callback: callback, }; }; }; }