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

@animini/react-dom

v0.3.0

Published

animini hook for React dom

Downloads

14

Readme

npm (tag) npm bundle size

Demo

https://animini.vercel.app/

Installation

For the React DOM

yarn add @animini/react-dom

For React Three Fiber

yarn add @animini/react-three

Instructions

import { useDrag } from '@use-gesture/react'
import { useAnimate, spring } from '@animini/react-dom'

const easing = spring()

export default function App() {
  const [ref, api] = useAnimate()

  useDrag(
    ({ active, movement: [x, y] }) => {
      api.start({ scale: active ? 1.2 : 1, x: active ? x : 0, y: active ? y : 0 }, (k) => ({
        immediate: k !== 'scale' && active,
        easing
      }))
    },
    { target: ref }
  )

  return <div ref={ref} />
}

Easings

Lerp

Lerp is the lightest, fastest and default easing algorithm for Animini. It supports a factor attribute that will change the momentum of the lerp.

import { useAnimate, lerp } from '@animini/react-dom'

const easing = lerp({ factor: 0.05 })
api.start({ x: 100 }, { easing })

Spring

import { useAnimate, spring } from '@animini/react-dom'

const easing = spring({
  tension: 170, // spring tension
  friction: 26, // spring friction
  mass: 1, // target mass
  velocity // initial velocity
})

api.start({ x: 100 }, { easing })

Ease (Bezier)

import { useAnimate, ease } from '@animini/react-dom'

const easing = ease(
  300, // duration of the ease in ms
  [0.25, 0.1, 0.25, 1] // coordinates of the bezier curve
)

api.start({ x: 100 }, { easing })

Inertia

Inertia aims at emulating a thrown object. Inertia will not reach its destination and only works if the value is already moving or if the easing is given an initial velocity.

Inertia supports min and max bounds which the element will bounce against as a rubberband bouncing on a wall.

import { useAnimate, inertia } from '@animini/react-dom'

const easing = inertia({
  momentum: 0.998,     // momentum of the inertia
  velocity: undefined, // initial velocity (leave it undefined to use the current velocity of the value)
  min: -100,           // min bound
  max: 100,            // max bound
  rubberband = 0.15    // elasticity factor when reaching bounds defined by min / max
})

api.start({ x: 100 }, { easing })