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

rxan-react

v1.1.4

Published

Rxan (RxJS Animation) adaptor library for react

Downloads

15

Readme

rxan-react

npm latest version npm total download github license github latest tag github commit from latest

React adaptor package for rxan

Requirement

This package requires react@^15||^16 and rxjs@^5||^6 as peer dependencies. You should install React and RxJS in your project to use this package.

How to install

To use with rxjs@^5

npm install --save rxan-core rxan-react

To use with rxjs@^6

npm install --save rxan-core@alpha rxan-react

How to use

Demo

You can see a live example at CodePen.

Code examples

Following examples assume that you use ES6 module. You can use ES6 module by using Webpack or Rollup or any other bundlers.

import React from 'react'
import { duration, easing } from 'rxan-core'
import { withRxan } from 'rxan-react'

const animation = duration()(500) // Creates values of 0~1
  .map(easing.sine) // Adds easing function to values of 0~1
  .map((v) => v * 100) // Maps values of 0~1 to values of 0~100

class App extends React.Component {
  componentDidMount() {
    this.props.start()
  }

  render() {
    // uses 'style' props since we name so using `withRxan`
    return (
      <img style={this.props.style} src='https://www.shareicon.net/data/256x256/2016/07/08/117367_logo_512x512.png' />
    )
  }
}

export withRxan(animation, {
  // maps props for result values of animation observable
  mapAnimationToProps(value, start) {
    return {
      start,
      style: {
        transform: 'translateX(-' + value + '%)'
      }
    }
  },
})(App)

API

  • withRxan(observable, config)(component)
    • observable: any observable.
    • config: configuration for withRxan
      • config.mapAnimationToProps(value, start, stop): mapping value, start, stop to props.
        This function should returns object or null/undefined.
        • value: current value of observable
        • start: function to start observable
        • stop: function to stop observable Default value is
        function (value, start, stop) {
          return {
            [config.valuePropName]: value,
            [config.startPropName]: start,
            [config.stopPropName]: stop,
          }
        }
      • config.autoStartAt: auto start observable when specified lifecycle method called.
        Possible values are: 'nothing', 'constructor', 'componentDidMount', 'componentWillUpdate', 'componentDidUpdate'.
        Default value is 'nothing'.
        Some lifecycle methods are excluded as intended, because these lifecycle methods are not of the component passed to withRxan, but of the component that withRxan makes (in the other words, you cannot control those).
        i.e., there is no state-related difference between constructor and componentWillMount, there is no shouldComponentUpdate-related difference between componentReceiveProps and componentWillUpdate, and so on. If you find any wierdness, please make an issue on github
      • config.stopBeforeAutoStart: whether stop or does not before auto start.
      • ~config.valuePropName: name for result values of observable. Default value is value.~
      • ~config.startPropName: name for the function that start running the observable. Default value is start.~
      • ~config.stopPropName: name for the function that stop running the observable. Default value is stop~
    • component: any React component that accepts config.mapAnimation(value, start, stop) as part of props.