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

ayncat

v1.0.11

Published

Real-time controlled animations with JavaScript and TypeScript

Downloads

3

Readme

Ayncat

The objective of Ayncat is to allow the development of animations controlled by JavaScript, not that they are executed with an action but that their entire execution is controlled by JavaScript.

Instalation

NPM

npm i ayncat --save

yanr

yarn add ayncat --save

Example

image

Animation in real time

You can see how the example using Ayncat (right) moves along with the scroll in real time, while the example not using Ayncat (left) runs completely on reaching the intersectionObserver.

Animation in gradients

Also Ayncat allows you to animate even the linear-gradient, while css does not allow you to animate the colors of a gradient.

Works with percents

works with anything that gives it a percentage and that percentage will be the time of the animation. This is what allows Ayncat to work in real time

Usage

Using Ayncat is very easy but first There are only two things to keep in mind! Look at the Recommendations before using Ayncat

To use ayncat

Import Ayncat and declare two variables in JSON format, one with the initial styles and one with the final styles

You can think of this as a "from" "to" in CSS

Example

import Ayncat from 'ayncat';

const prevStyles = {
    margin: "5px 3px",
    background: "#5544ff",
    transform: "rotate(25deg)",
}

const newStyles = {
    margin: "0px 0px",
    background: "#ff4455",
    tranform: "rotate(-25deg)",
}

Now call ayncat and pass it a css selector that you want to apply ayncat to, and the two variables you created.

    const cssSelector = ".myElements";
    const myElementsAyncat = new Ayncat(cssSelector, prevStyles, newStyles);

Lastly, run inside a function that sends some percentage to Ayncat.

    const handleMove = percent =>{
        myElementsAyncat.run = percent;
    }

For example, let's look at what this would look like applied to a scrollable element like in the first example

    const threshold = [];
    for(let i = 0.00; i < 1.00; i = i +0.01){
        threshold.push(i)
    }
    const options = {
        root: document.querySelector('#scrollArea'),
        rootMargin: "0px",
        threshold,
    }
    const handleScroll = ([entry])=> {
        const percent = entry * 100;
        myElementAyncat.run percent;
    }

    const observer = new IntersectionObserver(handleScroll, options);
    observer.observe(document.querySelector("#element")); //Element inside the scroll area

For more information about intersectionObserver visit the MDN Reference

Recomendations

| Using Ayncat is very easy, you just need to know CSS and some JavaScript | Just keep in mind to follow these recommendations.

1. Do not declare values ​​of different types in the same property

Example Do not do this ❌

        //INCORRET
        const prevStyles = {
            padding: "7pt",    //Done, the same unit of measure is used in both styles
            margin: "5px 0px", //Incorrect, different units of measure were used
        }

        const newStyles = {
            padding: "12pt",      //Done, the same unit of measure is used in both styles
            margin: "4rem 3rem", //Incorrect, different units of measure were used
        }

If you use px in one also do it in the other, Ayncat supports all types of css values, but it does not support the mixture of these in the same property.

Do it like this ✅

        //Corret ✅

        const prevStyles = {
            padding: "7pt",    //Done, the same unit of measure is used in both styles
            margin: "5px 0px", //Done, the same unit of measure is used in both styles
        }

        const newStyles = {
            padding: "12pt",   //Done, the same unit of measure is used in both styles
            margin: "4px 3px", //Done, the same unit of measure is used in both styles
        }

2. To avoid errors, remember to declare the same number of values in each property

Do not do this ❌

    //INCORRET ❌
    const prevStyle = {
        margin: "7px 5px 4px",
    }

    const newStyle = {
        margin: "0px", //Error two values are missing
    }

Do it like this ✅

    //INCORRET ❌
    const prevStyle = {
        margin: "7px 5px 4px",
    }

    const newStyle = {
        margin: "0px 0px 0px", // Done the same number of values
    }

How to use Ayncat

Code documentation