Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-easing-keyframes

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-easing-keyframes

Create CSS keyframe-based animations in React Native

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

React Native Easing Keyframes

Stable Release license

Create CSS keyframe-based animations in React Native

Installation

yarn add react-native-easing-keyframes

or

npm install react-native-easing-keyframes

Why do I need this?

Usually in timing animations, the easing function is applied to the entire duration of the animation. With the keyframes helper from this library, you can control what easing function to use in each keyframe during the animation.

import keyframes from 'react-native-easing-keyframes'

const easeInOut = Easing.bezier(0.42, 0.0, 0.58, 1.0)

const value = new Animated.Value(0)
Animated.timing(value, {
  duration: 1200,
  toValue: 100,
  easing: keyframes({ easing: easeInOut, keyframes: [0, 50, 100] }),
  useNativeDriver: true,
})

In the example above, keyframes will apply the easing function you want to use (easeInOut) to each keyframe, so easeInOut will be applied twice, from 0 to 50 and from 50 to 100.

You can also target a specific keyframe and apply a different easing function to it.

Animated.timing(value, {
  duration: 1200,
  toValue: 100,
  easing: keyframes({
    easing: easeInOut,
    keyframes: [0, 50, 100],
    easingsByKeyframe: { 50: Easing.linear },
  }),
  useNativeDriver: true,
})

API

keyframes

(config: Config) => EasingFunction

This function applies an easing function to each keyframe based on a config.

Config

An object that contains:

keyframes

number[]

And array of keyframes used in the animation.

This array must have at least 3 items. If you're animating from 0 to 100 then the first one should be 0 and the last one should be 100.

easing

(value: number) => number | default to Easing.inOut(Easing.ease)

The default easing function that will be used in all keyframes.

easingsByKeyframe

{ [key: number]: EasingFunction } | defaults to {}

You can specify the easing function you want to use for an individual keyframe. If no easing function is specified, the value from easing will be used.

Example

To run the example project, follow these steps:

  • Clone the repo
  • Run these commands
yarn
cd example
yarn && yarn start

Keywords

FAQs

Package last updated on 18 Apr 2021

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