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

transitto

v1.0.8

Published

A library for creating animations, transition and effects in react

Downloads

14

Readme

Description

Transitto is a library that allows you to simply add animations and transitions to your react application.

Why to use transitto ?

  1. It is very simple to understand and use.
  2. It can be customized.
  3. It is modern (It uses react hooks!).

Install

npm

npm install transitto

yarn

yarn add transitto

import (ES06)

import {useTransition} from 'transitto'

Hello World

import React from 'react';
import { useTransition } from 'transitto'

// a functional component that will render the view
const AnimateFontSize = () => {
    //change the value of fontSize from 1 to 40 in 2.5 seconds
    const fontSize = useTransition(1, 40, 2.5);

    return (
        <div style={{ fontSize }}>Hello World</div>
    )
}

export default AnimateFontSize

Animation in react

Usage

3 Simple Steps

Using this library is very simple.

  1. Install (see above).
  2. Import it (see above)
  3. use the useTransition hook

The useTransition hook

The useTransition is a react hook that allows you to animate a variable from one value to another value in a specific period of time. You can also (optionally) add a custom callback that will be called when the animation is over.

useTransition(from, to, seconds, callback)

| Argument | Optional? | Description | Type | Example | |---|---|---|---|---| | from | No | The initial value | int, float, string, color | 1/1.4/"hello"/"#ffcc99" | to | No | The target value | int, float, string, color | 10/15.2/"hello world"/"#ffffff" | seconds | No | The duration of the animation in seconds | float | 14/15.2 | callback | A callback function to be called when the animation is finished | function | () => console.log("the animation is finished)

Examples

Animating a string

If transitto detects a string it will animate the string starting from its initial value to its final value. In order for strings animations to work the final value should include the initial value so the animation.

| From | To | Correct/Wrong | |---|---|---| |""|"Hello"| Correct | | "FromValue" | "ToValueDoesntIncludeFrom" | Wrong | | "FullValue" | "Fu" | Wrong |

import React from 'react';
import { useTransition } from 'transitto'

const HelloString = () => {
    const HelloString = useTransition("", "Hello String", 1);

    return (
        <div style={{padding:"20px"}}>{HelloString}</div>
    )
}

export default HelloString

Animating a string with react

Animating a color

The transitto can detect whether a string is a color (HEX) such as #fff999 or #000 and then change the value accordingly.

import React, { useState } from 'react';
import { useTransition } from 'transitto'

const HelloColor = () => {
   const [done, setDone] = useState(false)
   
   // when done, call setDone(false)
   const HelloColor = useTransition("#ffcc99", "#cc99ff", 1, () => setDone(false));

   return (
       <div style={{ padding: "20px", fontSize: "40px", color: HelloColor }}>
           {done ? "Transition isFinished" : "Changing Color"}
       </div>
   )
}

export default HelloColor

Animating colors with react

Advanced usage

You can use this library with infinite possibilities. Remember that the all the arguments are editable, thus, you can use the useState or other hooks to change them in order to control the change of the speed (or in other cases create acceleration).

import React, { useState, useEffect } from 'react';
import { useTransition } from 'transitto'

const AdvancedAcceleration = () => { 
    const duration = useTransition(1, 25, 3);
    const topValue = useTransition(1, 200, 1/15*Math.exp(duration));
    const leftValue = useTransition(1, 400, 1/15*Math.exp(duration));

    return (
        <div style={{width:"20px", 
        height:"20px", 
        borderRadius:"10px", 
        backgroundColor:"#ffcc99", 
        "position":"absolute",
        top:topValue,
        left:leftValue}}>
        </div>
    )
}

export default AdvancedAcceleration

Advanced animation in react