All Projects → flipkart-incubator → animation-wrapper-view

flipkart-incubator / animation-wrapper-view

Licence: Apache-2.0 license
Declarative animations with imperative controls for RN/RNW.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to animation-wrapper-view

React Native demo
react-native实现网易新闻和美团,实现大部分页面。使用最新的react-navigation等组件,同时支持安卓和iOS设备。
Stars: ✭ 237 (+347.17%)
Mutual labels:  react-component, react-components
fluent-windows
🌈 React components that inspired by Microsoft's Fluent Design System.
Stars: ✭ 122 (+130.19%)
Mutual labels:  react-component, react-components
awesome-web-react
🚀 Awesome Web Based React 🚀 Develop online with React!
Stars: ✭ 31 (-41.51%)
Mutual labels:  react-component, react-components
React Border Wrapper
A wrapper for placing elements along div borders.
Stars: ✭ 147 (+177.36%)
Mutual labels:  react-component, react-components
react-ratings-declarative
A customizable rating component for selecting x widgets or visualizing x widgets
Stars: ✭ 41 (-22.64%)
Mutual labels:  react-component, declarative
Video React
A web video player built for the HTML5 world using React library.
Stars: ✭ 2,227 (+4101.89%)
Mutual labels:  react-component, react-components
shared-react-components-example
An example of a mono-repository of shared React components libraries!
Stars: ✭ 85 (+60.38%)
Mutual labels:  react-component, react-components
React Cassette Player
Simple ReactJS HTML5 audio player component built with SVG icons from The Noun Project.
Stars: ✭ 93 (+75.47%)
Mutual labels:  react-component, react-components
react-nes
React components for nes
Stars: ✭ 32 (-39.62%)
Mutual labels:  react-components, declarative
Registration-and-Login-using-MERN-stack
Simple Registration and Login component with MERN stack
Stars: ✭ 210 (+296.23%)
Mutual labels:  react-component, react-components
React Splitters
React splitter component, written in TypeScript.
Stars: ✭ 127 (+139.62%)
Mutual labels:  react-component, react-components
tiny-ui
⚛️ A friendly UI component set for React.js
Stars: ✭ 202 (+281.13%)
Mutual labels:  react-component, react-components
React Structured Data
React Structured Data provides an easy way to add structured data to your React apps
Stars: ✭ 120 (+126.42%)
Mutual labels:  react-component, react-components
Yoshino
A themable React component library!Flexible Lightweight PC UI Components built on React! Anyone can generate easily all kinds of themes by it!
Stars: ✭ 216 (+307.55%)
Mutual labels:  react-component, react-components
React Lazy
Universal lazy loader components using IntersectionObserver for React
Stars: ✭ 118 (+122.64%)
Mutual labels:  react-component, react-components
React-Jupyter-Viewer
A react component to embed .ipyb notebooks in a blog or something
Stars: ✭ 50 (-5.66%)
Mutual labels:  react-component, react-components
React Absolute Grid
An absolutely positioned, animated, filterable, sortable, drag and droppable, ES6 grid for React.
Stars: ✭ 910 (+1616.98%)
Mutual labels:  react-component, react-components
React Xmasonry
Simple, minimalistic and featured native masonry layout for React JS.
Stars: ✭ 62 (+16.98%)
Mutual labels:  react-component, react-components
best-of-react
🏆 A ranked list of awesome React open-source libraries and tools. Updated weekly.
Stars: ✭ 364 (+586.79%)
Mutual labels:  react-component, react-components
git-issue-react-electronjs
⚙️. ⚛️. A desktop application created with Electronjs and Reactjs to be cross-platform to manage and track GitHub issues.
Stars: ✭ 21 (-60.38%)
Mutual labels:  react-component, react-components

AnimationWrapperView is a collection of a well defined set of component level animations, that a developer can utilize just by providing some configurations. AnimationWrapperView will add plug and play type support to the already robust Animated API, and will take care of all the intricate details of each animation type.

Features

  • Power animation payload from anywhere (backend ? 😉)
  • Extremely light-weight (4KB gzipped + minified).
  • Out-of-box support for iOS, Android and RNW.
  • Great selection of well defined animations.
  • Declarative transformation animations with JSON.
  • Imperative controls to the animation state. (start/pause/reset)

Snack Playground

https://snack.expo.dev/@swapnil1104/animationwrapperview-playground

Steps to integrate

npm install animation-wrapper-view

Sample code

const bounceConfig: BounceAnimation = {
    type: AnimationType.BOUNCE,
    triggerType: AnimationTriggerType.ON_CLICK,
    bounceHeight: 20,
    animationDuration: 1000
};

<AnimationWrapperView animationConfig={bounceConfig}>
    {/* {your component} */}
</AnimationWrapperView>

AnimationWrapperView capabilities

Start, Pause and Reset Animation

private _wrapperRef: AnimationWrapperView | null;

render() {
    return (
        <AnimationWrapperView
            ref={(ref) => (this._wrapperRef = ref)}
            animationConfig={this.state.animationConfig}
            onAnimationFinish={this._onComplete}>
                {your component}
        </AnimationWrapperView>
    );
}

// Start animation from the view ref.
private _onPressToStart = (_: GestureResponderEvent) => {
    this._wrapperRef?.startAnimation();
}

// Pause animation from the view ref.
private _onPressToPause = (_: GestureResponderEvent) => {
    this._wrapperRef?.pauseAnimation();
}

// Reset animation from the view ref.
private _onPressToReset = (_: GestureResponderEvent) => {
    this._wrapperRef?.resetAnimation();
}

AnimationWrapperView props

Prop name Prop Type Description
animationConfig BaseAnimation Object which will contain all optional and non-optional parameters needed to render the animation, including AnimationType, AnimationTriggerType, etc.
onAnimationFinish () => void (optional) Callback function, if provided will be invoked once animation is finished.
onAnimationStart () => void (optional) Callback function, if provided will be invoked when the animation is triggered.

Types of supported Animations

Predefined Animations

JSON Based custom Animations

Different types of animation configs

To note, all the AnimationConfig objects extend from, so animationDuration, triggerType, triggerDelay, and interpolation properties are available to each of the animation definitions.

AnimationConfig Property name Type Description Demo
BaseAnimationConfig type AnimationType AnimationType enum will determine which type of animation will be rendered
triggerType AnimationTriggerType AnimationTriggerType enum defines the trigger critera of animation invokation; ON_LOAD, ON_CLICK
interpolation InterpolationDef InterpolationDef defines the property related to interpolation that will be applied to the animation timing function.
triggerDelay number This controls the animation trigger for ON_LOAD animation, it'll introduce delay before the animation is started
animationDuration number This defines how long the animation will be played before stopping.
BounceAnimationConfig bounceHeight number This param defines the value of Y axis translation which will give the visual appearance of the view bouncing. Bounce
FadeAnimationConfig initialOpacity number This will define the initial opacity of the view when the Animation starts playing Fae Out
finalOpacity number This will define the final opacity of the view once animation ends Fade In
RippleAnimationConfig rippleColor string This will define the ripple color, the input value could be a supported color name, or a hexcode value. Ripple
rippleCount number This determines how many ripples will be shown before animation ends
rippleDuration number This determines for how long an individual ripple will animate.
rippleIntervalDuration number This determines the time duration interval between each ripple.
rippleRadius number This will define the size of the ripple in its fully expanded state.
ScaleAnimationConfig fromScale number This will define the initial scale of the view before animation starts. Scale In
toScale number This will define the final scaale of the view once animation ends. Scale out
SlideHorizontalAnimationConfig initialOffset number This will define the initial offset from the view's original position before starting the animation. Slide in
finalOffset number This will define the final offset of the view once animation ends, 0 value will lead the view back to its original position. Slide out
direction SlideHorizontalDirection The direction param in this case will define the slide direction; 'ltr': left to right, or 'rtl': Right to left
SlideVerticalAnimationConfig initialOffset number This will define the initial offset from the view's original position before starting the animation.
finalOffset number This will define the final offset of the view once animation ends, 0 value will lead the view back to its original position.
direction SlideVerticalDirection The direction param in this case will define the slide direction; 'up_down': top to down, or 'down_up': below the view to upwards.
DraggableAnimationConfig TBD TBD TBD

In Action

Demore

Define your custom animations!

AnimationWrapperView also gives you the capability to define your custom animation using JSON. This tool is very powerful as it allows you to play with various transformation attributes that can be applied to any Animated.View.

  • A TransformDef object defines an individual piece of transformation, f(from) to t(to) value and the p(property) to transform.
  • An array of TransformDef along with the duration and the InterpolationDef will create an AnimationDef object. All the transformations defined in the array will play in parallel.
  • An array of AnimationDef definitions can be played in sequence to render any type of animation (limited by imagination :P).

Type definitions:

Type name params usage
TransformDef property: TransformType Defines the property to transform: scale, fade, opacity, translateY, rotate, translateX, rotateX, rotateY , scaleX, scaleY
to:number The starting value of the transformation
from:number The final value of transformation after animation
Type name params usage
InterpolationDef easing: EasingType Defines the easing that will be applied to the transformation set: linear, quad, circle, elastic, bounce, back.
params: InterpolationParams Some easing functions require extra params, we use this object to populate the optional params for easing functions, please note if a non optional param is not provided for the specified easing function, it will fallback to linear easing.
Type name params usage
InterpolationParams back: number https://reactnative.dev/docs/easing#back
bounciness: number https://reactnative.dev/docs/easing#bounce
bezierCurvePoints: Array<[x1: number, y1: number, x2: number, y2: number]> https://cubic-bezier.com/
Type name params usage
AnimationDef TransformDef[] An array of transformation functions can be defined, that will be applied to the object in parallel
duration Duration in which the set of transformations complete animating.
InterpolationDef This param will describe the easing function that will be applied to this set of transformations.

Multiple set of transformations can be played in a sequence.

Usage of JSON based custom animation

const animationConfig: JsonAnimationConfig = {
        type: AnimationType.JSON,
        triggerType: AnimationTriggerType.ON_LOAD,
        animationConfig: {
            transforms: [
                {
                    key: 'scale',
                    from: 0,
                    to: 1,
                },
                {
                    key: 'rotate',
                    from: 0,
                    to: 90,
                },
                {
                    key: 'rotateX',
                    from: 0,
                    to: 180,
                }
            ],
            duration: 1000,
            interpolation: {
                easing: "linear"
            }
        }
    };
<AnimationWrapperView animationConfig={bounceConfig}>
    {/* {your component} */}
</AnimationWrapperView>

Json Animation Demo Json Animation Demo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].