{"name":"rebound","version":"0.0.2","description":"A simple library for modeling spring dynamics","main":"rebound.js","author":{"name":"Facebook"},"license":"BSD","dependencies":{},"repository":{"type":"git","url":"git://github.com/facebook/rebound.git"},"bugs":{"url":"https://github.com/facebook/rebound/issues"},"keywords":["facebook","animation"],"homepage":"https://github.com/facebook/rebound","_id":"rebound@0.0.2","dist":{"shasum":"081f6314e3c994d054069b78f54c5cea561cf0f9","tarball":"http://registry-npm.ywwl.com/rebound/download/rebound-0.0.2.tgz","integrity":"sha512-6NzAHKsdxvQwBBBrC+KTmCK7yTZywuxNKK8Bw1IzYunfmzfeOFUx0yuS3ADVB4UFkZB0l4nDv3WpnT70Hkf9Ow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqyoECPEFgmi4vlHGggv7msLviSjrtb3LgzBL4HL/CiwIgfNbbnjADiMdgQwMj0VrbYQ5Zp+l60EnupLA69+tG0lA="}],"size":4069,"noattachment":false,"key":"/rebound/-/rebound-0.0.2.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"wbailey","email":"will.bailey@gmail.com"},"maintainers":[{"name":"wbailey","email":"will.bailey@gmail.com"}],"directories":{},"readme":"[![Build\nStatus](https://travis-ci.org/facebook/rebound-js.svg?branch=master)](https://travis-ci.org/facebook/rebound-js)\n\n# Rebound\n**Rebound** is a simple library that models Spring dynamics for the\npurpose of driving physical animations.\n\n## Origin\n[Rebound](http://facebook.github.io/rebound) was originally written\nin Java to provide a lightweight physics system for\n[Home](https://play.google.com/store/apps/details?id=com.facebook.home) and\n[Chat Heads](https://play.google.com/store/apps/details?id=com.facebook.orca)\non Android. It's now been adopted by several other Android\napplications. This JavaScript port was written to provide a quick\nway to demonstrate Rebound animations on the web for a\n[conference talk](https://www.youtube.com/watch?v=s5kNm-DgyjY). Since then\nthe JavaScript version has been used to build some really nice interfaces.\nCheck out [brandonwalkin.com](http://brandonwalkin.com) for an\nexample.\n\n## Overview\nThe Library provides a SpringSystem for maintaining a set of Spring\nobjects and iterating those Springs through a physics solver loop\nuntil equilibrium is achieved. The Spring class is the basic\nanimation driver provided by Rebound. By attaching a listener to\na Spring, you can observe its motion. The observer function is\nnotified of position changes on the spring as it solves for\nequilibrium. These position updates can be mapped to an animation\nrange to drive animated property updates on your user interface\nelements (translation, rotation, scale, etc).\n\nCheck out the\n[tests](http://facebook.github.io/rebound-js/browser_test/index.html), and\n[examples](http://facebook.github.io/rebound-js/examples) for more details.\n\n## Example\nHere's a simple example. Pressing and releasing on the logo below\nwill cause it to scale up and down with a springy animation.\n\n```html\n<div style=\"text-align:center; margin-bottom:50px; margin-top:50px\">\n  <img\n    src=\"http://facebook.github.io/rebound/images/rebound.png\"\n    id=\"logo\"\n  />\n</div>\n<script src=\"../rebound.min.js\"></script>\n<script>\n  function scale(el, val) {\n    el.style.mozTransform =\n    el.style.msTransform =\n    el.style.webkitTransform =\n    el.style.transform = 'scale3d(' + val + ', ' + val + ', 1)';\n  }\n  var el = document.getElementById('logo');\n\n  var springSystem = new rebound.SpringSystem();\n  var spring = springSystem.createSpring(50, 3);\n  spring.addListener({\n    onSpringUpdate: function(spring) {\n      var val = spring.getCurrentValue();\n      val = rebound.MathUtil.mapValueInRange(val, 0, 1, 1, 0.5);\n      scale(el, val);\n    }\n  });\n\n  el.addEventListener('mousedown', function() {\n    spring.setEndValue(1);\n  });\n\n  el.addEventListener('mouseout', function() {\n    spring.setEndValue(0);\n  });\n\n  el.addEventListener('mouseup', function() {\n    spring.setEndValue(0);\n  });\n</script>\n```\n\n### Here's how it works.\n\n```js\n// Get a reference to the logo element.\nvar el = document.getElementById('logo');\n\n// create a SpringSystem and a Spring with a bouncy config.\nvar springSystem = new rebound.SpringSystem();\nvar spring = springSystem.createSpring(50, 3);\n\n// Add a listener to the spring. Every time the physics\n// solver updates the Spring's value onSpringUpdate will\n// be called.\nspring.addListener({\n  onSpringUpdate: function(spring) {\n    var val = spring.getCurrentValue();\n    val = rebound.MathUtil\n                 .mapValueInRange(val, 0, 1, 1, 0.5);\n    scale(el, val);\n  }\n});\n\n// Listen for mouse down/up/out and toggle the\n//springs endValue from 0 to 1.\nel.addEventListener('mousedown', function() {\n  spring.setEndValue(1);\n});\n\nel.addEventListener('mouseout', function() {\n  spring.setEndValue(0);\n});\n\nel.addEventListener('mouseup', function() {\n  spring.setEndValue(0);\n});\n\n// Helper for scaling an element with css transforms.\nfunction scale(el, val) {\n  el.style.mozTransform =\n  el.style.msTransform =\n  el.style.webkitTransform =\n  el.style.transform = 'scale3d(' +\n    val + ', ' + val + ', 1)';\n}\n```\n\n### [Code of Conduct](https://code.facebook.com/codeofconduct)\n\nFacebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.\n\n","publish_time":1398881363186,"_cnpm_publish_time":1398881363186,"dist-tags":{"latest":"0.1.0"}}