New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@farazzshaikh/react-native-simple-animations

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@farazzshaikh/react-native-simple-animations

Simple Animations is a simple abstraction of the React Native Animated API.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

forthebadge

Simple Animations

Simple Animations is a simple abstraction of the React Native Animated API built for iOS.

demo

Installation

$ npm i @farazzshaikh/react-native-simple-animations --save
iOS
$ cd ios
$ pod install
$ cd ..

Usage

Import
import { RNSimpleAnimations } from '@farazzshaikh/react-native-simple-animations';
Initialize

Create new animation instance.

const animation = new RNSimpleAnimations(
    keyframes,
    delay,
    useNativeDriver
)
Assign Animation

Assign interpolated value to style property.

 <Animated.View
    style={{
        transform: [
            { translateX: animation.getValue() }
        ]
    }}
>
Play Animation
animation.start()

Example

Simple example of an animation that drives scale continuously. Example app in ./examples/src.

import React, { Component } from 'react';
import {
    Button,
    Animated,
    Easing
} from 'react-native';
import { RNSimpleAnimations } from '@farazzshaikh/react-native-simple-animations';

export default class Example extends Component {
    constructor(props) {
        super(props)
        // instantiation
        this.animation = new RNSimpleAnimations([1, 1.5, 1], 1000, true) 
          .setEasing(Easing.ease)
          .makeContinous()
    }
    render() {
        return (
            <>
                <Animated.View style={{
                    transform: [
                        scale: this.animation.getValue() // Assignment
                    ]
                }}>
                </Animated.View>
                <Button 
                    title={'Trigger'}
                    onPress={() => {
                        this.animation.start() // Execution
                    }}
                />
            </>
        )
    }
}

Documentation

Simple Animations is currently available with the following options:

constructor

Initialize Animation Instance.

new RNSimpleAnimations()
OptionsTypeDiscription
keyframesArray"An array of values representing animation points."
durationNumber"Duration of the animation in milliseconds."
useNativeDriverBoolean"Whether to use Native Driver. Note: must be consistant among all animaton drving the same element."
driverKeyframesArray"An array of values, representing animaiton events in terms of time. Size of this array and keyframes array must be the same."
.getValue()

Get interpolated value. Must be assigned to style property.

animation.getValue()
OptionsTypeDiscription
none--
.makeToggleable()

Make animation toggleable. i.e. play animation in reverse after playing it with play().

animation.makeToggleable()
OptionsTypeDiscription
none--
.makeContinous()

Make Animation continous . i.e. loop animation continously after calling start() till stop() is called.

animation.makeContinous()
OptionsTypeDiscription
none--
.setEasing()

Sets an easing function for animation interpolation.

animation.setEasing()
OptionsTypeDiscription
easingEasingFunctionEasing Function.
.setDelay()

Sets delay before start of an anmation cycle.

animation.setDelay()
OptionsTypeDiscription
delayNumberDelay in milliseconds.
.play()

Play animation.

animation.play()
OptionsTypeDiscription
callbackFunctionFunction that should be excicuted after animation starts.
.playBackward()

Play animation in reverse.

animation.playBackward()
OptionsTypeDiscription
none--
.start()

Start continuous animation.

animation.start()
OptionsTypeDiscription
callbackFunctionFunction that should be excicuted after animation starts.
.stop()

Stop continuous animation that has started.

animation.stop()
OptionsTypeDiscription
animationFunctionAnimation that has started.

Keywords

FAQs

Package last updated on 18 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc