react-native-reanimated
Advanced tools
Comparing version 1.3.0-alpha to 1.3.0
@@ -101,2 +101,3 @@ /** | ||
useCode: NOOP, | ||
createAnimatedComponent: Component => Component, | ||
}, | ||
@@ -103,0 +104,0 @@ |
{ | ||
"name": "react-native-reanimated", | ||
"version": "1.3.0-alpha", | ||
"version": "1.3.0", | ||
"description": "More powerful alternative to Animated library for React Native.", | ||
@@ -42,24 +42,12 @@ "scripts": { | ||
"devDependencies": { | ||
"babel-eslint": "^8.2.3", | ||
"babel-jest": "23.0.1", | ||
"babel-preset-react-native": "4.0.0", | ||
"eslint": "^4.19.1", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-config-standard": "^11.0.0", | ||
"eslint-plugin-import": "^2.12.0", | ||
"eslint-plugin-jest": "^21.17.0", | ||
"eslint-plugin-node": "^6.0.1", | ||
"eslint-plugin-promise": "^3.8.0", | ||
"eslint-plugin-react": "^7.9.1", | ||
"eslint-plugin-react-native": "^3.2.1", | ||
"eslint-plugin-standard": "^3.1.0", | ||
"@types/react": "^16.9.0", | ||
"@types/react-native": "^0.61.0", | ||
"babel-jest": "^24.9.0", | ||
"husky": "^0.14.3", | ||
"jest": "23.1.0", | ||
"jest-react-native": "18.0.0", | ||
"jest": "^24.9.0", | ||
"lint-staged": "^8.0.0-beta.1", | ||
"prettier": "^1.13.4", | ||
"react": "16.4.1", | ||
"react-dom": "^16.0.0-beta.5", | ||
"react-native": "^0.56.0", | ||
"react-test-renderer": "^16.0.0-alpha.12" | ||
"prettier": "^1.13.7", | ||
"react": "^16.9.0", | ||
"react-native": "^0.61.0", | ||
"react-test-renderer": "16.9.0" | ||
}, | ||
@@ -66,0 +54,0 @@ "lint-staged": { |
@@ -15,3 +15,7 @@ // Project: https://github.com/kmagiera/react-native-reanimated | ||
ImageStyle, | ||
TransformsStyle | ||
TransformsStyle, | ||
View as ReactNativeView, | ||
Text as ReactNativeText, | ||
Image as ReactNativeImage, | ||
ScrollView as ReactNativeScrollView | ||
} from 'react-native'; | ||
@@ -75,8 +79,14 @@ namespace Animated { | ||
export interface DecayState { | ||
export interface AnimationState { | ||
finished: AnimatedValue<number>; | ||
velocity: AnimatedValue<number>; | ||
position: AnimatedValue<number>; | ||
time: AnimatedValue<number>; | ||
} | ||
export interface PhysicsAnimationState extends AnimationState { | ||
velocity: AnimatedValue<number>; | ||
} | ||
export type DecayState = PhysicsAnimationState; | ||
export interface DecayConfig { | ||
@@ -90,6 +100,3 @@ deceleration: Adaptable<number>; | ||
export interface TimingState { | ||
finished: AnimatedValue<number>; | ||
position: AnimatedValue<number>; | ||
time: AnimatedValue<number>; | ||
export interface TimingState extends AnimationState { | ||
frameTime: AnimatedValue<number>; | ||
@@ -104,9 +111,4 @@ } | ||
export interface SpringState { | ||
finished: AnimatedValue<number>; | ||
velocity: AnimatedValue<number>; | ||
position: AnimatedValue<number>; | ||
prevPosition?: AnimatedValue<number>; | ||
time: AnimatedValue<number>; | ||
} | ||
export type SpringState = PhysicsAnimationState; | ||
export interface SpringConfig { | ||
@@ -182,9 +184,19 @@ damping: Adaptable<number>; | ||
// components | ||
export const View: ComponentClass<AnimateProps<ViewStyle, ViewProps>>; | ||
export const Text: ComponentClass<AnimateProps<TextStyle, TextProps>>; | ||
export const Image: ComponentClass<AnimateProps<ImageStyle, ImageProps>>; | ||
export const ScrollView: ComponentClass< | ||
export class View extends Component<AnimateProps<ViewStyle, ViewProps>> { | ||
getNode(): ReactNativeView; | ||
} | ||
export class Text extends Component<AnimateProps<TextStyle, TextProps>> { | ||
getNode(): ReactNativeText; | ||
} | ||
export class Image extends Component< | ||
AnimateProps<ImageStyle, ImageProps> | ||
> { | ||
getNode(): ReactNativeImage; | ||
} | ||
export class ScrollView extends Component< | ||
AnimateProps<ViewStyle, ScrollViewProps> | ||
>; | ||
export const Code: ComponentClass<CodeProps>; | ||
> { | ||
getNode(): ReactNativeScrollView; | ||
} | ||
export class Code extends Component<CodeProps> {} | ||
export function createAnimatedComponent(component: any): any; | ||
@@ -263,5 +275,8 @@ | ||
// react-native makes within Animated | ||
export function event( | ||
argMapping: ReadonlyArray<Mapping>, | ||
config?: {}, | ||
type EventArgFunc<T> = (arg: T) => Node<number>; | ||
type EventMapping<T> = T extends object ? { [K in keyof T]?: EventMapping<T[K]> | EventArgFunc<T[K]> } : Adaptable<T> | EventArgFunc<T>; | ||
type EventMappingArray<T> = T extends Array<any> ? { [I in keyof T]: EventMapping<T[I]> } : [EventMapping<T>] | ||
export function event<T>( | ||
argMapping: T extends never ? ReadonlyArray<Mapping> : Readonly<EventMappingArray<T>>, | ||
config?: {}, | ||
): (...args: any[]) => void; | ||
@@ -328,9 +343,3 @@ | ||
// configuration | ||
// `addWhitelistedNativeProps` will likely be removed soon, and so is | ||
// intentionally not exposed to TypeScript. If it is needed, it could be | ||
// uncommented here, or just use | ||
// `(Animated as any).addWhitelistedNativeProps({ myProp: true });` | ||
// addWhitelistedNativeProps(props: { [key: string]: true }): void; | ||
export function addWhitelistedNativeProps(props: { [key: string]: true }): void; | ||
} | ||
@@ -337,0 +346,0 @@ |
@@ -106,3 +106,3 @@ # react-native-reanimated | ||
Allows to specify how views that get mounted durion animation transition get animated. In addition to the above parameters you can specify the type of animation using `type` prop. The possible values are: `fade`, `scale`, `slide-top`, `slide-bottom`, `slide-left`, `slide-right`. | ||
Allows to specify how views that get mounted during animation transition get animated. In addition to the above parameters you can specify the type of animation using `type` prop. The possible values are: `fade`, `scale`, `slide-top`, `slide-bottom`, `slide-left`, `slide-right`. | ||
@@ -109,0 +109,0 @@ ### `<Transition.Out>` |
@@ -34,3 +34,5 @@ import AnimatedNode from './AnimatedNode'; | ||
// TODO: cache some typical static values (e.g. 0, 1, -1) | ||
return v instanceof AnimatedNode ? v : new InternalAnimatedValue(v); | ||
return v instanceof AnimatedNode | ||
? v | ||
: InternalAnimatedValue.valueForConstant(v); | ||
} | ||
@@ -37,0 +39,0 @@ |
@@ -11,2 +11,13 @@ import AnimatedNode from './AnimatedNode'; | ||
const CONSTANT_VALUES = new Map(); | ||
function initializeConstantValues() { | ||
if (CONSTANT_VALUES.size != 0) { | ||
return; | ||
} | ||
[0, -1, 1, -2, 2].forEach(v => | ||
CONSTANT_VALUES.set(v, new InternalAnimatedValue(v, true)) | ||
); | ||
} | ||
/** | ||
@@ -17,13 +28,23 @@ * This class has been made internal in order to omit dependencies' cycles which | ||
export default class InternalAnimatedValue extends AnimatedNode { | ||
constructor(value) { | ||
static valueForConstant(number) { | ||
initializeConstantValues(); | ||
return ( | ||
CONSTANT_VALUES.get(number) || new InternalAnimatedValue(number, true) | ||
); | ||
} | ||
constructor(value, constant = false) { | ||
super({ type: 'value', value: sanitizeValue(value) }); | ||
this._startingValue = this._value = value; | ||
this._animation = null; | ||
this._constant = constant; | ||
} | ||
__detach() { | ||
ReanimatedModule.getValue( | ||
this.__nodeID, | ||
val => (this.__nodeConfig.value = val) | ||
); | ||
if (!this._constant) { | ||
ReanimatedModule.getValue( | ||
this.__nodeID, | ||
val => (this.__nodeConfig.value = val) | ||
); | ||
} | ||
this.__detachAnimation(this._animation); | ||
@@ -30,0 +51,0 @@ super.__detach(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
363408
10
3818
0