File tree Expand file tree Collapse file tree
packages/plugin-reanimated/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @plextv/react-lightning-plugin-reanimated " : patch
3+ ---
4+
5+ feat: Add a placeholder withSequence
Original file line number Diff line number Diff line change 1- import type {
2- AnimationObject ,
3- withDelay as withDelayRN ,
4- } from 'react-native-reanimated-original' ;
1+ import type { AnimatedValue } from '../animation/AnimatedValue' ;
52
63export type WithDelayFn = (
7- ...args : Parameters < typeof withDelayRN >
8- ) => AnimationObject ;
4+ delayMs : number ,
5+ animation : AnimatedValue ,
6+ reduceMotion ?: string ,
7+ ) => AnimatedValue ;
98
10- export const withDelay : WithDelayFn = (
11- _delayMs ,
12- nextAnimation ,
13- _reduceMotion ,
14- ) : AnimationObject => {
15- // withTiming and withSpring supports `delay`. The client should pass it directly
16- return typeof nextAnimation === 'function'
17- ? ( nextAnimation as ( ) => AnimationObject ) ( )
18- : ( nextAnimation as AnimationObject ) ;
9+ export const withDelay : WithDelayFn = ( delayMs , animation ) => {
10+ animation . lngAnimation . delay = delayMs ;
11+
12+ return animation ;
1913} ;
Original file line number Diff line number Diff line change 11import type { AnimatedValue } from '../animation/AnimatedValue' ;
2- import type { AnimationType } from '../types/AnimationType' ;
32
4- export function withRepeat (
3+ export type WithRepeatFn = (
4+ animation : AnimatedValue ,
5+ repeatCount ?: number ,
6+ reverse ?: boolean ,
7+ ) => AnimatedValue ;
8+
9+ export const withRepeat : WithRepeatFn = (
510 animation : AnimatedValue ,
611 repeatCount = 2 ,
712 reverse = false ,
8- ) : {
9- isHigherOrder : boolean ;
10- onFrame : ( ) => void ;
11- onStart : ( ) => void ;
12- reps : number ;
13- current : AnimatedValue < AnimationType > ;
14- callback : ( ) => void ;
15- startValue : number ;
16- reduceMotion : boolean ;
17- } {
13+ ) => {
14+ animation . lngAnimation . loop = repeatCount === - 1 ;
1815 animation . lngAnimation . repeat = repeatCount ;
1916 animation . lngAnimation . stopMethod = reverse ? 'reverse' : false ;
2017
21- return {
22- isHigherOrder : true ,
23- onFrame : ( ) : void => { } ,
24- onStart : ( ) : void => { } ,
25- reps : 0 ,
26- current : animation ,
27- callback : ( ) : void => { } ,
28- startValue : 0 ,
29- reduceMotion : false ,
30- } ;
31- }
18+ return animation ;
19+ } ;
Original file line number Diff line number Diff line change 1+ import type {
2+ AnimatableValue ,
3+ AnimationObject ,
4+ withSequence as withSequenceRN ,
5+ } from 'react-native-reanimated-original' ;
6+
7+ export function withSequence (
8+ _reduceMotion : string ,
9+ ...animations : AnimatableValue [ ]
10+ ) : ReturnType < typeof withSequenceRN > {
11+ console . error (
12+ '[Reanimated] withSequence is unsupported. Consider building a custom animation in lightning directly instead. Returning just the first animation.' ,
13+ ) ;
14+
15+ const returnAnimation = animations [ 0 ] ;
16+
17+ if ( ! returnAnimation ) {
18+ throw new Error (
19+ '[Reanimated] withSequence requires at least one animation.' ,
20+ ) ;
21+ }
22+
23+ return typeof returnAnimation === 'function'
24+ ? ( returnAnimation as ( ) => AnimationObject ) ( )
25+ : ( returnAnimation as AnimationObject ) ;
26+ }
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export { useAnimatedStyle } from './exports/useAnimatedStyle';
5252export { useComposedEventHandler } from './exports/useComposedEventHandler' ;
5353export { withDelay } from './exports/withDelay' ;
5454export { withRepeat } from './exports/withRepeat' ;
55+ export { withSequence } from './exports/withSequence' ;
5556export { withSpring } from './exports/withSpring' ;
5657export { withTiming } from './exports/withTiming' ;
5758
You can’t perform that action at this time.
0 commit comments