All Projects â†’ gvergnaud â†’ rx-ease

gvergnaud / rx-ease

Licence: other
Spring animation operator for rxjs 🦚✨

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rx-ease

Ngx Restangular
Restangular for Angular 2 and higher versions
Stars: ✭ 787 (+4818.75%)
Mutual labels:  reactive, rxjs, observable
Redux Most
Most.js based middleware for Redux. Handle async actions with monadic streams & reactive programming.
Stars: ✭ 137 (+756.25%)
Mutual labels:  reactive, rxjs, observable
Rxviz
Rx Visualizer - Animated playground for Rx Observables
Stars: ✭ 1,471 (+9093.75%)
Mutual labels:  reactive, rxjs, observable
Marble
Marble.js - functional reactive Node.js framework for building server-side applications, based on TypeScript and RxJS.
Stars: ✭ 1,947 (+12068.75%)
Mutual labels:  reactive, rxjs, observable
React Eva
Effects+View+Actions(React distributed state management solution with rxjs.)
Stars: ✭ 121 (+656.25%)
Mutual labels:  reactive, rxjs, observable
rxrest
Reactive rest library
Stars: ✭ 33 (+106.25%)
Mutual labels:  reactive, rxjs, observable
reactive-graphql
A GraphQL implementation based around RxJS, very well suited for client side only GraphQL usage
Stars: ✭ 58 (+262.5%)
Mutual labels:  reactive, rxjs
rxjs-proxify
Turns a Stream of Objects into an Object of Streams
Stars: ✭ 34 (+112.5%)
Mutual labels:  rxjs, observable
drawer
A touch-enabled drawer component for the modern web.
Stars: ✭ 26 (+62.5%)
Mutual labels:  reactive, rxjs
BittrexRx
BittrexRx is a rxjs node wrapper for the Bittrex Api
Stars: ✭ 16 (+0%)
Mutual labels:  rxjs, observable
realar
5 kB Advanced state manager for React
Stars: ✭ 41 (+156.25%)
Mutual labels:  reactive, observable
observe-component
A library for accessing React component events as reactive observables
Stars: ✭ 36 (+125%)
Mutual labels:  rxjs, observable
immerx-state
Reactive, fractal and no-nonsense state management with Immer
Stars: ✭ 19 (+18.75%)
Mutual labels:  reactive, observable
rxact
Rxact is an observable application management for Javascript app
Stars: ✭ 21 (+31.25%)
Mutual labels:  rxjs, observable
bassdrum
reactive, type safe components with preact and rxjs.
Stars: ✭ 44 (+175%)
Mutual labels:  reactive, rxjs
monogram
Aspect-oriented layer on top of the MongoDB Node.js driver
Stars: ✭ 76 (+375%)
Mutual labels:  rxjs, observable
mst-effect
💫 Designed to be used with MobX-State-Tree to create asynchronous actions using RxJS.
Stars: ✭ 19 (+18.75%)
Mutual labels:  rxjs, observable
reactive-search
Incremental search using React and RxJS
Stars: ✭ 15 (-6.25%)
Mutual labels:  reactive, rxjs
polyrhythm
A 3Kb full-stack async effect management toolkit over RxJS. Uses a Pub-Sub paradigm to orchestrate Observables in Node, or the browser (ala Redux Saga). Exports: channel, listen, filter, trigger, after.
Stars: ✭ 23 (+43.75%)
Mutual labels:  rxjs, observable
react-with-observable
Use Observables with React declaratively!
Stars: ✭ 108 (+575%)
Mutual labels:  rxjs, observable

rx-ease

An animation operator for RxJs Observables!

  • Physic based. The animation seemlessly interupts itself if a new value is emitted before it completes.
  • Performant, emits on requestAnimationFrame at 60fps.
  • Typescript first class support.
  • Versatile, Works with any kind of data structures (Object, arrays, single values).

Install

npm install rxjs rx-ease

The gist

Interpolate between emitted numbers

You can simply use the ease operator in an observable pipeline. You need to configure the ease operator with two numbers: a stiffness value and a damping value. See the presets sections bellow for example of configurations.

import { interval } from 'rxjs'
import { take, map, startWith } from 'rxjs/operators'
import ease from 'rx-ease'

const draw = x =>
  Array(Math.floor(x))
    .fill('#')
    .join('')

const progress$ = interval(1000).pipe(
  startWith(0),
  map(i => * 100),
  ease(120, 18),
  map(draw)
)

progress$.subscribe(progress => console.log(progress))
// will log =>
// #
// ####
// ########
// #############
// #################
// ######################
// ##########################
// ##############################
// ##################################
// ######################################
// #########################################
// ############################################
// ##############################################
// ################################################
// ##################################################
// ####################################################
// #####################################################
// ######################################################
// #######################################################
// ########################################################
// #########################################################
// ##########################################################
// ##########################################################
// ##########################################################
// ##########################################################

Interpolate several properties of an object

If your Observable emits an object instead of a single number, you can use the ease operator to interpolate the values of one or several properties of this object. Just pass to ease an object of the same shape as the observed value with a config for each property you want to ease.

import { fromEvent } from 'rxjs'
import { map } from 'rxjs/operators'
import ease from 'rx-ease'

const circle = document.querySelector('.circle')

const position$ = fromEvent(document, 'click').pipe(
  map(e => ({ x: e.clientX, y: e.clientY })),
  ease({
    x: [120, 18],
    y: [120, 18]
  })
)

position$.subscribe(({ x, y }) => {
  circle.style.transform = `translate(${x}px, ${y}px)`
})

Api

Similarly to react-motion, rx-ease is a spring animation operator. To configure the animation you need to pass a stiffness and a damping value in an array like [stiffness, damping] (for example [120, 18]).

Easing a single value

signature
type Config = [number, number]
ease: (config: Config) => (stream: Observable<number>) => Observable<number>
example
import { interval } from 'rxjs'
import ease from 'rx-ease'

const easedInterval$ = interval(1000).pipe(
  map(x => x * 100),
  ease([170, 26])
)

Easing values of an array

signature
ease: (config: Config[]) => (stream: Observable<number[]>) => Observable<number[]>
example
import { fromEvent } from 'rxjs'
import ease from 'rx-ease'

const easedMousePosition$ = fromEvent(window, 'mousemove').pipe(
  map(e => [e.clientX, e.clientY]),
  ease([
    [170, 26],
    [170, 26],
  ])
)

Easing properties of an object

signature
ease: (config: Record<K, Config>) => (stream: Observable<Record<K, Config>>) => Observable<Record<K, Config>>
example
import { fromEvent } from 'rxjs'
import ease from 'rx-ease'

const easedMousePosition$ = fromEvent(window, 'mousemove').pipe(
  map(e => ({
    x: e.clientX,
    y: e.clientY
  }),
  ease({
    x: [170, 26],
    y: [170, 26],
  })
)

presets

  • noWobble: equivalent to passing [170, 26]
  • gentle: equivalent to passing [120, 14]
  • wobbly: equivalent to passing [180, 12]
  • stiff: equivalent to passing [210, 20]
import ease, { presets } from 'rx-ease'

interval(1000).pipe(
  map(x => x * 100),
  ease(...presets.stiff)
)

Credits

This was heavily inspired by @chenglou's react-motion.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].