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

universal-css-animations

v1.0.2

Published

A lightweight and easy-to-use CSS animations library for web applications.

Downloads

17

Readme

CSS-Animations

A lightweight and easy-to-use CSS animations library for web applications.

Table of Contents

  1. Introduction
  2. Installation
  3. Usage
  4. Vanilla JavaScript (WIP)
  5. React
  6. Vue.js
  7. Available Animations
  8. Customization
  9. Contributing
  10. License

Introduction

CSS-Animations is a versatile library that offers a collection of pre-built CSS animations for use in web applications. It provides seamless integration with popular frameworks such as React and Vue.js as well as compatibility with vanilla JavaScript projects.

Installation

To install the library, use the npm package manager:

npm install universal-css-animations

Alternatively, you can include the animations.css file in your project and link it in your HTML file:

<link rel="stylesheet" href="path/to/animations.css" />

Usage

Vanilla JavaScript

Import the css-animate function:

import { cssAnimate } from 'universal-css-animations/vanilla';

Apply an animation to an element:

const element = document.querySelector('.your-element');
cssAnimate({
    element:element, 
    animationName:'fadeIn', 
    duration:1, //in seconds
    callbackFunction:callbackFunction
});

React

Import the css-animate function:

import { cssAnimate } from 'universal-css-animations';

Apply an animation to a React component:

import {useRef, useState} from 'react'
import useCssAnimate from 'universal-css-animations/react';
import "./App.css"
function App() {
    const elementRef = useRef();
    const [animationName, setAnimationName] = useState('swing');
    const [duration, setDuration] = useState(1);
    const animations = useCssAnimate({elementRef, animationName, duration:`${duration}s`,deps:[animationName,duration]});
    return (
        <div className="grid">
            <h1>CSS Animations Preview (React)</h1>
            <div>
                <select onChange={(e) => {
                    setAnimationName(e.target.value)
                }
                }>
                    <option>Select animation</option>
                    {animations.map(animation => <option key={animation} value={animation}>{animation.replace("-"," ")}</option>)}
                </select>
                <input onChange={e=>setDuration(`${e.target.value}`)} title="Control Animation Speed" type="range" value={duration} min="1" max="10" name="animation-duration"/>
                <div>Adjust slider to control animation speed</div>
            </div>

            <div id={"elem"} ref={elementRef}>{animationName.replaceAll("-"," ")} will take {duration}s</div>
        </div>
    );
}

export default App

Vue.js

Bind the css-animate to app (main.js):

import { createApp } from 'vue'
import './style.css'

import App from './App.vue'
import cssAnimateDirective from "universal-css-animations/vue";

let app = createApp(App);

app.use(cssAnimateDirective);

app.mount('#app')

Apply an animation to a Vue component:

<script setup>
import {ref} from 'vue'
import {Animations as options} from "universal-css-animations";

const animationName = ref("swing");
const animationDuration = ref(1);
</script>
<template>
  <div className="grid">
    <h1>CSS Animations Preview (Vue)</h1>
    <div>
      <select @change="(e)=>animationName=e.target.value">
        <option>Select Animation</option>
        <option v-for="option in options" :value="option">
          {{ option }}
        </option>
      </select>
      <input :min="1" :max="10" :value="animationDuration" type="range" @change="e=>animationDuration=e.target.value"/>
      <div>Adjust slider to control animation speed</div>
    </div>

    <div id="elem" v-css-animate="{animationName,animationDuration}">{{ animationName }}</div>
  </div>

</template>

Available Animations

Here is a list of the animations included in the library:

  • fadeIn
  • fadeOut
  • slideIn
  • slideOut
  • bounce
  • rotate ...

For a complete list, please refer to the animations.css file.

Customization

You can customize the animations by either overriding the existing CSS classes or creating your own custom animations. Simply modify the animations.css file or create a new CSS file with your desired animation properties.

Contributing

Contributions are welcome! If you would like to improve the library or add new animations, please follow these steps:

  • Fork the repository on GitHub.
  • Clone your forked repository to your local machine.
  • Create a new branch for your changes: git checkout -b your-feature-branch-name.
  • Make your changes or additions to the codebase. Be sure to follow the existing coding style and conventions.
  • Test your changes to ensure they work as expected and do not introduce any new bugs.
  • Commit your changes, making sure to write clear and descriptive commit messages.
  • Push your changes to your forked repository on GitHub.
  • Create a pull request against the original repository, detailing the changes you made and why they are beneficial.
  • Wait for your pull request to be reviewed and merged.

If you find any issues or have suggestions, please create an issue on the GitHub repository.

License

CSS-Animations is licensed under the MIT License. This means you are free to use, modify, and distribute the library as long as you include the original copyright and license notice in any copy of the software or its derivatives. For more information, please refer to the LICENSE file in the repository.