GithubHelp home page GithubHelp logo

morenoh149 / react-tweenable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mandarinconlabarba/react-tweenable

0.0 3.0 0.0 261 KB

A simple declarative component built on react-tween-state

Home Page: http://mandarinconlabarba.github.io/react-tweenable/example/index.html

JavaScript 99.95% HTML 0.05%

react-tweenable's Introduction

React Tweenable

A simple component and mixin that wraps the excellent react-tween-state.

Please check out the Demo.

Why?

I think react-tween-state is awesome, but I didn't like all the touches required to make it work. If you're building an app, you don't want to make API calls on a per-component basis. react-tweenable aims to make animations/tweens declarative.

Install

npm install --save react-tweenable

General Usage

Component

var React = require('react');

var Tweenable = require('react-tweenable')


//Then in your render:

var tween = {"top" : {from : -100, to: 0 }, "position": "relative};

return <Tweenable tween={tween}><div>...some content</div></Tweenable>;

Mixin


//A tweenable button

var React = require('react/addons');

var Tweenable = require('react-tweenable').Mixin;

var Button = React.createClass({

  mixins: [Tweenable],

  render: function () {
    return <button style={this.state.tweenable}>Submit</button>
  }
});

//Then in your consumer component

render: function() {

    var tween = {"top" : {from : -100, to: 0 }};

    return <Button tween={tween} />;
}


Props

tween={Object}

Your tween config

Example:


var tween = {"top" : {
                easing: Tweenable.Easing.easeInOutQuad, //any easing function with the right signature will do, `react-tween-state` provides plenty https://github.com/chenglou/react-tween-state/blob/master/easingTypes.js
                duration: 500,
                from: 0,
                to: 100
                }
            };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.