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

@foundit/micro-animations

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foundit/micro-animations

A light wrapper around the Web Animation API to swiftly create awaitable micro animations from JS.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
748
increased by49%
Maintainers
1
Weekly downloads
 
Created
Source

Micro Animation

A light wrapper around the Web Animation API to swiftly create awaitable micro animations from JS.

Often times using transitions in the CSS creates constant custom code for every animation, prone to timing problem between CSS timing and JS. By moving the transitions from CSS to JS the result is both cleaner code, less code and perfect timing as a result.

Install

npm install @foundit/microAnimation

Usage

Minimum is to pass an element and a transformEnd object containing the properties you want to animate to. Transform start is picked up from the element's computed style.

async function close() {
  await microAnimation({
    element,
    duration: 300,
    transformEnd: { opacity: 0 },
  })
  removeElement()
}

For a keyframe animation, pass an array of transformEnd objects. The offset property is optional, and defaults to 0. In the example below, the background color will change to orangered at 70% of the animation.

...
await microAnimation({
  element,
  duration: 1000,
  easing: 'ease-out',
  transformEnd: [{
     backgroundColor: 'orangered',
     opacity: 1, offset: 0.7
   }, {
     transform: "translateX(0)",
     backgroundColor: 'blue'
   }]
 ...

FAQs

Package last updated on 17 Sep 2023

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