Skip to content

Xesenix/xes-rx-tween

Repository files navigation

Build Status Coverage Status Greenkeeper badge bitHound Overall Score Known Vulnerabilities

Observable Tween with Rxjs

This library supplies you with observable for tweening over numbers.

Usage

Install

npm i xes-rx-tween

Basic usage example:

import { tweenObservable } from 'xes-rx-tween';

tweenObservable(2000, 0, 100)
	.subscribe((interpolationValue) => {
		// do some stuff with interpolationValue for example
		object.x = interpolationValue;
	})

You also can do some more stuff with tweened value for example use some tweening functions on them:

import { tweenObservable } from 'xes-rx-tween';

const easingFunction = (x) => Math.sin(x * Math.PI);

tweenObservable(2000, 1, 1.5)
	.map(easingFunction)
	.subscribe((interpolationValue) => {
		// do some stuff with interpolationValue for example
		object.scale = interpolationValue;
	})

Tests

Single run

npm run test

Watch mode

npm run test:watch