Socket
Socket
Sign inDemoInstall

easing-animation-frames

Package Overview
Dependencies
1
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    easing-animation-frames

Lightweight library for creating animation


Version published
Weekly downloads
590
decreased by-19.84%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Easing Animation Frames

Build Status

npm i easing-animation-frames

This is a tiny library for creating CPU-friendly easing animations with requestAnimationFrame API and Robert Penner's easing equations. Suggestions and pull requests for optimization are welcome.

Bar Animation

How to use

Select an easing type (cubicInOut by default) and pass a callback function to run for every animation frame which manipulates target DOM elements.

Minimum settings
easingAnimationFrames({
  template: updateBarWidth // Callback function to run for every frame, which receives progress from 0 to 1
});
With optional settings
easingAnimationFrames({
  easingType: "quadInOut", // Easing function name
  duration: 3000, // Animation duration in milliseconds
  template: updateBarWidth, // Callback function to run for every frame, which receives progress from 0 to 1
  complete: animationComplete, // Callback funciton to run on completion
});

Duration is set to be 4,000 milliseconds by default, which you can change. Once the animation starts, the callback function (template) receives the progress value (from 0 to 1) that you can use to render the animation. The example above uses (progress * 75)% for the width of the bar, based on the time passed.

npm start to see the example.

The template function also provides stop and resume functions, if you want to stop the animation before it completes and resume it.

React Easing Animation is a React HOC implementation of this library.

Browser Support

It uses requestAnimationFrame, which should be supported for most of the modern browsers.

Keywords

FAQs

Last updated on 27 Dec 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc