Skip to content

Commit 96f0942

Browse files
dryganetserictraut
authored andcommitted
AnimatedValue available for ReactXP modules (#144)
* AnimatedValue available for ReactXP modules * AnimatedValue moved to Types to make it available for plugings * Revert "AnimatedValue available for ReactXP modules" This reverts commit 7ab9c81.
1 parent c0cf725 commit 96f0942

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

src/android/Animated.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export var Animated = {
3838
Text: AnimatedText as typeof RX.AnimatedText,
3939
TextInput: CommonAnimated.TextInput as typeof RX.AnimatedTextInput,
4040
View: CommonAnimated.View as typeof RX.AnimatedView,
41-
Value: CommonAnimated.Value as typeof RX.AnimatedValue,
41+
Value: CommonAnimated.Value as typeof Types.AnimatedValue,
4242
Easing: CommonAnimated.Easing as Types.Animated.Easing,
4343
timing: CommonAnimated.timing as Types.Animated.TimingFunction,
4444
delay: CommonAnimated.delay,

src/common/Interfaces.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,7 @@ export interface IAnimatedValue {
8282
addListener(callback: any): number;
8383
removeListener(id: string): void;
8484
removeAllListeners(): void;
85-
interpolate(config: any): AnimatedValue;
86-
}
87-
88-
export abstract class AnimatedValue implements IAnimatedValue {
89-
constructor(val: number) {
90-
// No-op
91-
}
92-
abstract setValue(value: number): void;
93-
abstract addListener(callback: any): number;
94-
abstract removeListener(id: string): void;
95-
abstract removeAllListeners(): void;
96-
abstract interpolate(config: any): AnimatedValue;
85+
interpolate(config: any): IAnimatedValue;
9786
}
9887

9988
export abstract class App {
@@ -317,7 +306,7 @@ export interface Animated {
317306
Image: typeof AnimatedImage;
318307
Text: typeof AnimatedText;
319308
View: typeof AnimatedView;
320-
Value: typeof AnimatedValue;
309+
Value: typeof Types.AnimatedValue;
321310
Easing: Types.Animated.Easing;
322311
timing: Types.Animated.TimingFunction;
323312
parallel: Types.Animated.ParallelFunction;

src/common/Types.ts

+36-25
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,25 @@ export interface FlexboxStyle {
7979
position?: 'absolute' | 'relative';
8080
}
8181

82+
export abstract class AnimatedValue implements RX.IAnimatedValue {
83+
constructor(val: number) {
84+
// No-op
85+
}
86+
abstract setValue(value: number): void;
87+
abstract addListener(callback: any): number;
88+
abstract removeListener(id: string): void;
89+
abstract removeAllListeners(): void;
90+
abstract interpolate(config: any): AnimatedValue;
91+
}
92+
8293
export interface AnimatedFlexboxStyle {
83-
height?: RX.AnimatedValue;
84-
width?: RX.AnimatedValue;
94+
height?: AnimatedValue;
95+
width?: AnimatedValue;
8596

86-
top?: RX.AnimatedValue;
87-
right?: RX.AnimatedValue;
88-
bottom?: RX.AnimatedValue;
89-
left?: RX.AnimatedValue;
97+
top?: AnimatedValue;
98+
right?: AnimatedValue;
99+
bottom?: AnimatedValue;
100+
left?: AnimatedValue;
90101
}
91102

92103
// ------------------------------------------------------------
@@ -110,16 +121,16 @@ export interface TransformStyle {
110121

111122
export interface AnimatedTransformStyle {
112123
transform?: [{
113-
perspective?: RX.AnimatedValue;
114-
rotate?: RX.AnimatedValue;
115-
rotateX?: RX.AnimatedValue;
116-
rotateY?: RX.AnimatedValue;
117-
rotateZ?: RX.AnimatedValue;
118-
scale?: RX.AnimatedValue;
119-
scaleX?: RX.AnimatedValue;
120-
scaleY?: RX.AnimatedValue;
121-
translateX?: RX.AnimatedValue;
122-
translateY?: RX.AnimatedValue;
124+
perspective?: AnimatedValue;
125+
rotate?: AnimatedValue;
126+
rotateX?: AnimatedValue;
127+
rotateY?: AnimatedValue;
128+
rotateZ?: AnimatedValue;
129+
scale?: AnimatedValue;
130+
scaleX?: AnimatedValue;
131+
scaleY?: AnimatedValue;
132+
translateX?: AnimatedValue;
133+
translateY?: AnimatedValue;
123134
}];
124135
}
125136

@@ -143,9 +154,9 @@ export interface ViewAndImageCommonStyle extends FlexboxStyle, TransformStyle {
143154
}
144155

145156
export interface AnimatedViewAndImageCommonStyle extends AnimatedFlexboxStyle, AnimatedTransformStyle {
146-
borderRadius?: RX.AnimatedValue;
147-
backgroundColor?: RX.AnimatedValue;
148-
opacity?: RX.AnimatedValue;
157+
borderRadius?: AnimatedValue;
158+
backgroundColor?: AnimatedValue;
159+
opacity?: AnimatedValue;
149160
}
150161

151162
// ------------------------------------------------------------
@@ -244,8 +255,8 @@ export interface TextStyle extends ViewStyle {
244255
export type TextStyleRuleSet = StyleRuleSet<TextStyle>;
245256

246257
export interface AnimatedTextStyle extends AnimatedViewAndImageCommonStyle {
247-
color?: RX.AnimatedValue;
248-
fontSize?: RX.AnimatedValue;
258+
color?: AnimatedValue;
259+
fontSize?: AnimatedValue;
249260
}
250261

251262
export type AnimatedTextStyleRuleSet = StyleRuleSet<AnimatedTextStyle>;
@@ -260,8 +271,8 @@ export interface TextInputStyle extends TextStyle {
260271
export type TextInputStyleRuleSet = StyleRuleSet<TextInputStyle>;
261272

262273
export interface AnimatedTextInputStyle extends AnimatedViewAndImageCommonStyle {
263-
color?: RX.AnimatedValue;
264-
fontSize?: RX.AnimatedValue;
274+
color?: AnimatedValue;
275+
fontSize?: AnimatedValue;
265276
}
266277

267278
export type AnimatedTextInputStyleRuleSet = StyleRuleSet<AnimatedTextInputStyle>;
@@ -977,7 +988,7 @@ export interface NavigatorProps extends CommonProps {
977988
renderScene: (route: NavigatorRoute) => JSX.Element;
978989
navigateBackCompleted?: () => void;
979990
// NOTE: Arguments are only passed to transitionStarted by the experimental navigator
980-
transitionStarted?: (progress?: RX.AnimatedValue,
991+
transitionStarted?: (progress?: RX.IAnimatedValue,
981992
toRouteId?: string, fromRouteId?: string,
982993
toIndex?: number, fromIndex?: number) => void;
983994
transitionCompleted?: () => void;
@@ -1046,7 +1057,7 @@ export module Animated {
10461057
outputRange: (number | string)[];
10471058
}
10481059

1049-
export type TimingFunction = (value: RX.AnimatedValue, config: TimingAnimationConfig) => CompositeAnimation;
1060+
export type TimingFunction = (value: RX.IAnimatedValue, config: TimingAnimationConfig) => CompositeAnimation;
10501061
export var timing: TimingFunction;
10511062

10521063
export type SequenceFunction = (animations: Array<CompositeAnimation>) => CompositeAnimation;

src/native-common/Animated.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class AnimatedView extends RX.AnimatedView {
142142
}
143143

144144
var timing = function(
145-
value: RX.AnimatedValue,
145+
value: Types.AnimatedValue,
146146
config: Types.Animated.TimingAnimationConfig)
147147
: Types.Animated.CompositeAnimation {
148148

src/web/Animated.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export abstract class Animation {
7575
var animatedValueUniqueId = 0;
7676

7777
// The animated value object
78-
export class Value extends RX.AnimatedValue {
78+
export class Value extends Types.AnimatedValue {
7979
_value: number | string;
8080
_listenerId: number;
8181
_animationId: number;

0 commit comments

Comments
 (0)