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

@amalgamaco/react-native-animated-toggle-button

v0.2.1

Published

A two states button that can be animated when transitioning between them.

Downloads

2

Readme

ReactNative - Animated Toggle Button

A two states button that can be animated when trasitioning between them.

Example

Installation

Requirements

This library depends on lottie-react-native in order to work. You must add this library as a dependency before installing this package.

yarn add lottie-react-native
yarn add [email protected]

The version to install depends on the react native version being used in the project, you can see the corresponding version of the library for each react native version next:

| App built in React Native version | Requires lottie-react-native version | Requires lottie-ios version | |-----------------------------------|--------------------------------------|-----------------------------| | >= 0.59 | 3.0.2 | 3.0.3 | | >= 0.60 | 4.0.2 | 3.2.3 | | >= 0.63 | 4.0.3 | 3.2.3 | | >= 0.64 | 4.1.3 | 3.2.3 | | >= 0.66 | latest | 3.2.3 |

With yarn

yarn add @amalgamaco/react-native-animated-toggle-button

With npm

npm install @amalgamaco/react-native-animated-toggle-button

Usage

The AnimatedToggleButton component can be used in a declarative way:

import React, { useState } from 'react';
import { AnimatedToggleButton } from '@amalgamaco/react-native-animated-toggle-button';

import animation from './animation.json';

const BasicExample = () => {
   const [ isActive, setIsActive ] = useStsate( false );

   return (
      <AnimatedToggleButton
         source={animation}
         isActive={isActive}
         onPress={() => setIsActive( !isActive )}
         activeFrame={20}
         inactiveFrame={0}
         toActiveFrameRange={[ 10, 20 ]}
         toInactiveFrameRange={[ 20, 30 ]}
      />
   );
}

There is also a non-button animated component that you can use if you don't need a button and want to show only an animated view between two states:

import React from 'react';
import { AnimatedIcon } from '@amalgamaco/react-native-animated-toggle-button';

import animation from './animation.json';

const BasicExample = () => (
   <AnimatedIcon
      source={animation}
      isActive={true}
      activeFrame={20}
      inactiveFrame={0}
      toActiveFrameRange={[ 10, 20 ]}
      toInactiveFrameRange={[ 20, 30 ]}
   />
);

API

The AnimatedToggleButton accepts several props. They are describe in the following table:

| Prop | Description | Default | |----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------- | | source | Mandatory - The source of animation. Can be referenced as a local asset by a string, or remotely with an object with a uri property, or it can be an actual JS object of an animation, obtained (for example) with something like require('../path/to/animation.json'). | None | | inactiveFrame | Mandatory - A number indicating the still frame to show when the animation is in inactive state. | None | | activeFrame | Mandatory - A number indicating the still frame to show when the animation is in active state. | None | | toActiveFrameRange | Mandatory - A range of two numbers indicating an start and end frame for the animation to show when the button passes from inactive to active state. The end frame must be always greater that the start frame. Example: [ 10, 20 ] | None | | toInactiveFrameRange | Mandatory - A range of two numbers indicating an start and end frame for the animation to show when the button passes from active to inactive state. The end frame must be always greater that the start frame. Example: [ 20, 30 ] | None | | isActive | A boolean flag indicating whether or not the button is in an active state or not. If the button is active it will show the animation frame set in the activeFrame prop, otherwise it will show the animation frame set in the inactiveFrame prop. | false | | onPress | A callback to call when the button is pressed. | undefined | | speed | The speed the animation will progress. Sending a negative value will reverse the animation |1| | iconSize | The size of the animated icon. This prop will set the width and height of the animation view. |50| | style | Style attributes for the view, as expected in a standard View. | undefined | | containerStyle | Style attributes for the container view, as expected in a standard View. | undefined |

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT