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

reanimated-formula

v2.0.0-beta.3

Published

<p align="center"> <img src="https://github.com/JonnyBurger/reanimated-formula/raw/master/reanimated.gif"/> </p>

Downloads

20

Readme

reanimated-formula

React Native Reanimated gives us a new level of control over React Native Animations and allows us to run complex animations with 60fps.

With that new power, we write so complex expressions that it can become hard to read. In Reanimated, all math expressions are functions, which leads us to write the operator before the values instead of the natural inbetween. For example, we write multiply(2, 2) instead of 2 * 2. If you nest the expressions, your statement might end with ))))). The more you nest, the harder it gets to read.

reanimated-formula allows you to write expressions in a more familiar and natural way.

Installation

npm install reanimated-formula

Example Usage

import Animated from 'react-native-reanimated'
import formula from 'reanimated-formula'

const active = new Animated.Value(0)
const offsetY = new Animated.Value(0)
const swipeProgress = new Animated.Value(0)

const Animation = () => (
    <Animated.View
        style={{
            // Using Reanimated functions
            translateY: Animated.cond(
                active,
                Animated.min(
                    Animated.add(
                        15,
                        Animated.multiply(offsetY, swipeProgress)
                    ),
                    0
                ),
                0
            ),
            // Using reanimated-formula
            translateY: formula`${active} ? min(15 + ${offsetY} * ${swipeProgress}, 0) : 0`
        }}
    >
    </Animated.View>
)

Implemented functions

| Reanimated Functions from Reanimated.* | reanimated-formula Use inside formula``
|----------------------------|----------------------------------------------------------------------| | add(a, b) | ${a} + ${b} | sub(a, b) | ${a} - ${b}
| multiply(a, b) | ${a} * ${b}
| divide(a, b) | ${a} / ${b} | sin(a) | sin(${a}) | cos(a) | cos(${a}) | tan(a) | tan(${a}) | sqrt(a) | sqrt(${a}) | min(a, b, c) | min(${a}, ${b}, ${c})or min(${[a, b, c]}) | max(a, b, c) | max(${a}, ${b}, ${c})or max(${[a, b, c]}) | pow(a, b, c) | ${a} ** ${b} ** ${c}or pow(${[a, b, c]}) | and(a, b) | ${a} && ${b} | or(a, b) | ${a} \|\| ${b} | modulo(a, b) | ${a} % ${b} | exp(a) | exp(${a}) | asin(a) | asin(${a}) | atan(a) | atan(${a}) | acos(a) | acos(${a}) | round(a) | round(${a}) | floor(a) | floor(${a}) | ceil(a) | ceil(${a}) | abs(a) | abs(${a}) | eq(a, b) | ${a} === ${b} | neq(a, b) | ${a} !== ${b} | greaterThan(a, b) | ${a} > ${b} | lessThan(a, b) | ${a} < ${b} | greaterOrEq(a, b) | ${a} >= ${b} | lessOrEq(a, b) | ${a} <= ${b} | not(a) | !${a} | diff(a) | diff(${a}) | acc(a) | acc(${a}) | defined(a) | defined(${a}) | cond(a, b) | ${a} ? ${b} : 0 | cond(a, b, c) | ${a} ? ${b} : ${c} | concat(a, 'deg') | deg(${a}) | set(a, b) | set(${a}, ${b})

Development

Standard project that can be cloned and set up using npm install.
Unit tests can be run using npm test.

Credits

License

MIT

See also

This is a library with a very similar purpose that I only found after I have written this module.It uses a Babel macro to compile the math expressions into standard Reanimated code, which should make it more performant. On the other hand, it doesn't support operators like &&, ||, ?, :, >=, so I think both libraries have merit.