{"name":"react-tween-state","version":"0.0.3","description":"React animation.","main":"index.js","directories":{"examples":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/chenglou/react-tween-state.git"},"keywords":["react","animation","tween","transition","state","interactive","mixin","interpolation"],"author":{"name":"Cheng Lou"},"license":"BSD","bugs":{"url":"https://github.com/chenglou/react-tween-state/issues"},"homepage":"https://github.com/chenglou/react-tween-state","_id":"react-tween-state@0.0.3","_shasum":"2e2b3eee85d662516f172b2076c80c46baff7d37","_from":".","_npmVersion":"1.4.7","_npmUser":{"name":"chenglou","email":"chenglou92@gmail.com"},"maintainers":[{"name":"chenglou","email":"chenglou92@gmail.com"}],"dist":{"shasum":"2e2b3eee85d662516f172b2076c80c46baff7d37","tarball":"http://registry-npm.ywwl.com/react-tween-state/download/react-tween-state-0.0.3.tgz","integrity":"sha512-YwG6cohFVB7YsxsZKjOTW9gS9Pch+01rFBy1e1i2QOP+wtmRU9uLxmlIWTM9+EPvCtZfHDi0S2IExyWngqzhBQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCYQyCaY/VVGwejR/ZO7Z3wO/L9nRdyiucNwMUlBmqp5gIgUmz7qB/nyhmhl9WXF5722XaSVzW+lMJDq0oY0kwd8Mw="}],"size":5744,"noattachment":false,"key":"/react-tween-state/-/react-tween-state-0.0.3.tgz"},"readme":"# [React](http://facebook.github.io/react/) Tween State\n\nThe equivalent of React's `this.setState`, but for animated tweens: `this.tweenState`.\n\n[Live demo](https://rawgit.com/chenglou/react-tween-state/master/examples/index.html) and [source](https://github.com/chenglou/react-tween-state/tree/master/examples).\n\nNpm:\n```sh\nnpm install react-tween-state\n```\n\nBower:\n```sh\nbower install react-tween-state\n```\n\n## API\n\nExample usage:\n\n```js\nvar tweenState = require('react-tween-state');\nvar React = require('react');\n\nvar App = React.createClass({\n  mixins: [tweenState.Mixin],\n  getInitialState: function() {\n    return {left: 0};\n  },\n  handleClick: function() {\n    this.tweenState('left', {\n      easing: tweenState.easingTypes.easeInOutQuad,\n      duration: 500,\n      endValue: this.state.left === 0 ? 400 : 0\n    });\n  },\n  render: function() {\n    var style = {\n      position: 'absolute',\n      width: 50,\n      height: 50,\n      backgroundColor: 'lightblue',\n      left: this.getTweeningValue('left')\n    };\n    return <div style={style} onClick={this.handleClick} />;\n  }\n});\n```\n\nThe library exports `Mixin`, `easingTypes` and `stackBehavior`.\n\n#### `this.tweenState(path: String | Array<String>, configuration: Object)`\n\nThis first calls `setState` **and puts your fields straight to their final value**. Under the hood, it creates a layer that interpolates from the old value to the new. You can retrieve that tweening value using `getTweeningValue` below.\n\n`path` is the name of the state field you want to tween. If it's deeply nested, e.g. to animate `c` in {a: {b: {c: 1}}}, provide the path as `['a', 'b', 'c']`\n\n`configuration` is of the following format:\n\n```js\n{\n  easing: easingFunction,\n  duration: timeInMilliseconds,\n  delay: timeInMilliseconds,\n  beginValue: aNumber,\n  endValue: aNumber,\n  onEnd: endCallback,\n  stackBehavior: behaviorOption\n}\n```\n\n  - `easing` (default: `easingTypes.easeInOutQuad`): the interpolation function used. react-tween-state provides [frequently used interpolation](https://github.com/chenglou/tween-functions/blob/master/index.js) (exposed under `easingTypes`). To plug in your own, the function signature is: `(currentTime: Number, beginValue: Number, endValue: Number, totalDuration: Number): Number`.\n  - `duration` (default: `300`).\n  - `delay` (default: `0`). *\n  - `beginValue` (default: the current value of the state field).\n  - `endValue`.\n  - `onEnd`: the callback to trigger when the animation's done. **\n  - `stackBehavior` (default: `stackBehavior.ADDITIVE`). Subsequent tween to the same state value will be stacked (added together). This gives a smooth tween effect that is iOS 8's new default. [This blog post](http://ronnqvi.st/multiple-animations/) describes it well. The other option is `stackBehavior.DESTRUCTIVE`, which replaces all current animations of that state value by this new one.\n\n\\* For a destructive animation, starting the next one with a delay still immediately kills the previous tween. If that's not your intention, try `setTimeout` or additive animation. `DESTRUCTIVE` + `duration` 0 effectively cancels all in-flight animations, **skipping the easing function**.\n\n\\*\\* For an additive animation, since the tweens stack and never get destroyed, the end callback is effectively fired at the end of `duration`.\n\n#### `this.getTweeningValue(path: String | Array<String>)`\nGet the current tweening value of the state field. Typically used in `render`.\n\n## License\nBSD.\n","publish_time":1409705294853,"_cnpm_publish_time":1409705294853,"dist-tags":{"latest":"0.1.5"}}