npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@plutonium-js/react-atomic

v1.0.4

Published

Atomic is an ultra lightweight React component that simplifies the management and control of CSS animations.

Downloads

3

Readme

Plutonium Atomic - [react animation component]

About

Atomic is an ultra lightweight React component that simplifies the management and control of CSS animations.

  • Define pure CSS keyframe or transition style animations directly in the JSX
  • Control play states such as 'running', 'pause', 'reset', 'cancel', 'to', and 'from'
  • Easily pause, reverse, reset, and more from any event
  • Add state to CSS key frame at-rules ('@keyframe')
  • All standard CSS features are supported such as delay, direction, duration, ease, etc...
  • Add any child components and elements without conflict

Links

Bookmarks

Installation

> npm install @plutonium-js/react-atomic

:arrow_up_small:

Usage

  • Module

    Using ES6...

    import Atomic from '@plutonium-js/react-atomic';

    Or when using CommonJS...

    const {Atomic} = require('@plutonium-js/react-atomic');
  • CDN Script Tag

    Add the component directly to a web page.

    <script src="https://cdn.jsdelivr.net/npm/@plutonium-js/react-atomic@1/dist/bundle.min.js"></script>

:arrow_up_small:

Create Component

To create a basic Atomic component, add the 'Atomic' tag to your JSX. The child content can be any text, elements, or other React components.

class App extends Component {
   render() {
      return (
         <Atomic>your content here</Atomic>
      );
   }
}

:arrow_up_small:

Animate

To animate an Atomic component add the animate property. The example below fades in the element while rotating it one revolution.

render() {
   return <Atomic
      animate = {{
         keyframes:`
            from {
               transform:rotate(0deg);opacity:0;
            }
            to {
               transform:rotate(360deg);opacity:1;
            }
         `,
         animation:"2s ease",
         playState:'running'
       }}
   >Plutonium Atomic!</Atomic>;
}

:arrow_up_small:

Key Frames or Transitions

Animations can be defined using CSS key frames or transitions (only use one method per component and not both). For key frames, provide standard CSS at-rule syntax as a string. (the example below uses an ES6 template string)

keyframes:`
   from {
      transform:rotate(0deg);opacity:0;
   }
   to {
      transform:rotate(360deg);opacity:1;
   },
   animation:"2s ease",
   playState:'running'
`

To use transitions...

transitions:{
   transform:{
      from:'rotate(0deg)',
	  to:'rotate(360deg)'
   },
   opacity:{
      from:0,
	  to:1
   }
   animation:"2s ease",
   playState:'running'
}

With transitions the 'to' value is required. With both key frames and transitions the 'from' value is optional. If 'from' is omitted the animation or transition will start at the elements applied style value.

:arrow_up_small:

Adding State

Add state to any part of the animate property or the entire value. When rendering animation state changes Atomic resets the animation and resumes the current play state.

TIP: To add state to an ES6 template string (backtick '`' enclosed content) use the standard interpolation data syntax '${data}'...

keyframes:`
   from {
      transform:rotate(0deg);
   }
   to {
      transform:rotate(${this.state.myRotation}deg);
   }
`

:arrow_up_small:

Control

The API exposes the 'setPlayState' method for controlling animations. The example below resets the key frame animation when clicking the element.

return <Atomic
   ref = {this.myAtomicElm = React.createRef()}
   onClick = {e => {
      this.myAtomicElm.current.setPlayState('reset');
   }}
   animate = {{
      keyframes:`
         from {
            transform:rotate(0deg);
         }
         to {
            transform:rotate(360deg);
         }
      `,
      animation:"2s ease",
      playState:'running'
   }}
>Plutonium Atomic!</Atomic>;

Supported key frame play state types...

  • 'running'
  • 'paused'
  • 'toggle' (toggles between 'running' and 'paused')
  • 'reset'
  • 'cancel'
  • 'none'

Supported transition play state types...

  • 'to'
  • 'from'
  • 'running' (same as 'to')
  • 'paused' (same as 'from')
  • 'toggle' (toggles between 'to' and 'from')
  • 'reset'
  • 'cancel'
  • 'none'

:arrow_up_small:

License

Released under the MIT license

Author: Jesse Dalessio / Plutonium.dev

:arrow_up_small: