impulse-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 02fe2fa4f4db5789ec01bc7e4d7416996bb10410
4
+ data.tar.gz: 81a0a099412d146e72760e33da87a26220b138ef
5
+ SHA512:
6
+ metadata.gz: 414e84a0a9e40cbe4e2d22a5ab057c7719bd7806706028463f1db6086cb96521bec5bb2615dc1816c3c7c05eb3b32e87e24fd6df9634ae6553605b9baf1a8775
7
+ data.tar.gz: f808a9881d26b37d5acb14220fafe359a4428d62f3aaae83294ce74cd77a496cde2219d1377c97fafc2634fe4ebea3d53f280cddab80855cb11296ada8623e56
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in somelibrary.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sherwyn Goh
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Somelibrary
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'impulse-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install impulse-rails
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/sherwyngoh/somelibrary/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "impulse-rails"
7
+ spec.version = '0.0.1'
8
+ spec.authors = ["Sherwyn Goh"]
9
+ spec.email = ["sherwyn.lj.goh@gmail.com"]
10
+ spec.summary = %q{Impulse Js for the rails 3.1+ asset pipeline}
11
+ spec.description = %q{Currently for Impulse version 0.1.0}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_dependency "railties", ">= 3.1"
23
+ end
@@ -0,0 +1,4 @@
1
+ module ImpulseRails
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1 @@
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Impulse=e()}}(function(){var e,t,n;return function r(e,t,n){function i(o,u){if(!t[o]){if(!e[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(s)return s(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return i(n?n:t)},l,l.exports,r,e,t,n)}return t[o].exports}var s=typeof require=="function"&&require;for(var o=0;o<n.length;o++)i(n[o]);return i}({1:[function(e,t,n){var r=e("./body");var i=e("./simulation");var s=e("./boundary");var o=e("./animation");var u=e("./vector");var a=e("./util").height;var f=t.exports=o({defaultOptions:{acceleration:1e3,bounce:false,minBounceDistance:5,damping:.2,restitution:.2},onStart:function(e,t,n,o,f,l){var c=n.sub(t).normalize();if(typeof o.acceleration==="number"){var h=c.mult(o.acceleration)}else{var h=u(o.acceleration)}var p=c.mult(o.bounceAcceleration||h),d=false,v=s({left:n.x>t.x?-Infinity:n.x,right:n.x>t.x?n.x:Infinity,top:n.y>t.y?-Infinity:n.y,bottom:n.y>t.y?n.y:Infinity});if(n.sub(t).norm()<.001&&e.norm()<.001){return f.done(n,e)}var m=o.restitution||o.damping;var g=this._body=r(e,t,{accelerate:function(e,t){if(d)return p;else return h},update:function(e,t){if(v.contains(e)){f.state(e,t)}else{if(o.bounce&&Math.abs(a(p.norm(),t.norm()*m,0))>o.minBounceDistance){d=true;g.position=u(n);g.velocity.selfMult(-o.damping);f.state(n,g.velocity)}else{f.done(n,t)}}}});i.addBody(this._body)},onEnd:function(){i.removeBody(this._body)}})},{"./animation":2,"./body":4,"./boundary":5,"./simulation":11,"./util":13,"./vector":14}],2:[function(e,t,n){function f(e){var t=function(t,n){var r=this;this._opts=n;this._phys=t;this._onStart=e.onStart;this._onEnd=e.onEnd;this._defaultOpts=e.defaultOptions;this._ended=new i(function(e,t){r._resolve=e;r._reject=t});this.start=this.start.bind(this)};u(t.prototype);t.prototype=a;return t}var r=e("lodash.defaults"),i=window.Promise||e("promise"),s=e("./boundary"),o=e("./vector"),u=e("component-emitter");var a={to:function(e,t){if(e instanceof s)this._to=e;else this._to=o(e,t);return this},velocity:function(e,t){this._velocity=o(e,t);return this},from:function(e,t){this._from=o(e,t);return this},_updateState:function(e,t){this._phys.position(e);this._phys.velocity(t)},cancel:function(){this._onEnd();this._running=false;this._reject()},running:function(){return this._running||false},start:function(){var e=this,t=this._from?this._from:this._phys.position(),n=this._to?this._to:this._phys.position(),i=this._velocity?this._velocity:this._phys.velocity(),o=r({},this._opts||{},this._defaultOpts);var u={state:function(t,n){e._updateState(t,n)},done:function(t,n){e._updateState(t,n);e._onEnd();e._running=false;e._resolve({position:t,velocity:n})},cancel:function(t,n){e._updateState(t,n);e._onEnd();e._running=false;e._reject()}};this._phys._startAnimation(this);this._running=true;if(n instanceof s)n=n.nearestIntersect(t,i);this._onStart(i,t,n,o,u);return e._ended}};t.exports=f},{"./boundary":5,"./vector":14,"component-emitter":16,"lodash.defaults":17,promise:24}],3:[function(e,t,n){function a(e,t,n){this._phys=e;this._opts=r({},n||{},u);this._position=e.position();this._velocity=e.velocity();if(typeof t.position==="function")this._attachment=t.position.bind(t);else this._attachment=t}var r=e("lodash.defaults"),i=e("./vector"),s=e("./simulation"),o=e("./body");var u={tension:100,damping:10,seperation:0,offset:{x:0,y:0}};t.exports=a;a.prototype.position=function(e,t){if(arguments.length===0){return this._position}if(this._body)this._body.position=this._position=i(e,t);else this._position=i(e,t)};a.prototype.velocity=function(e,t){if(this._body)this._body.velocity=this._velocity=i(e,t);else this._velocity=i(e,t)};a.prototype.cancel=function(e,t){this._running=false;s.removeBody(this._body)};a.prototype.stop=function(e,t){this._running=false;s.removeBody(this._body)};a.prototype.running=function(e,t){return this._running};window.unit=0;a.prototype.start=function(){var e=this._attachment,t=this._opts,n=this._phys,r=this._velocity,i=this._position,u=this;n._startAnimation(this);this._running=true;var a=this._body=o(r,i,{accelerate:function(n,r){var i=n.position.selfSub(e()),s=i.norm(),o=i.normalize();if(o.x===0&&o.y===0){o.x=o.y=1;o.normalize()}var u=o.selfMult(-t.tension).selfMult(s-t.seperation).selfSub(n.velocity.selfMult(t.damping));return u},update:function(e,r){u._position=a.position;u._velocity=a.velocity;if(t.offset){var i=e.add(t.offset);n.position(i)}else{n.position(e)}n.velocity(r)}});s.addBody(a);return this}},{"./body":4,"./simulation":11,"./vector":14,"lodash.defaults":17}],4:[function(e,t,n){function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);this.previousPosition=this.position=r(t);this.velocity=r(e);this._fns=n}var r=e("./vector");t.exports=i;i.prototype.update=function(e){var t=this.previousPosition.clone().lerp(this.position,e);this._fns.update(t,this.velocity)};i.prototype.accelerate=function(e,t){return this._fns.accelerate(e,t)};i.prototype.atRest=function(){return this.velocity.norm()<.01};i.prototype.atPosition=function(e){return this.position.sub(r(e)).norm()<.01}},{"./vector":14}],5:[function(e,t,n){function i(e,t,n){return e>=t&&e<=n}function s(e,t,n){var r=(e-t.y)/n.y;return t.add(n.clone().mult(r))}function o(e,t,n){var r=(e-t.x)/n.x;return t.add(n.clone().mult(r))}function u(e){if(!(this instanceof u))return new u(e);this.left=typeof e.left!=="undefined"?e.left:-Infinity;this.right=typeof e.right!=="undefined"?e.right:Infinity;this.top=typeof e.top!=="undefined"?e.top:-Infinity;this.bottom=typeof e.bottom!=="undefined"?e.bottom:Infinity}var r=e("./vector");t.exports=u;u.prototype.applyDamping=function(e,t){var n=e.x,i=e.y;if(n<this.left)n=this.left-(this.left-n)*t;if(i<this.top)i=this.top-(this.top-i)*t;if(n>this.right)n=this.right-(this.right-n)*t;if(i>this.bottom)i=this.bottom-(this.bottom-i)*t;return r(n,i)};u.prototype.contains=function(e){return e.x>=this.left&&e.x<=this.right&&e.y>=this.top&&e.y<=this.bottom};u.prototype.nearestIntersect=function(e,t){var n=r(t).normalize(),e=r(e),u,a,f;if(t.y<0)u=s(this.top,e,n);if(t.y>0)u=s(this.bottom,e,n);if(u&&i(u.x,this.left,this.right))return u;if(t.x<0)u=o(this.left,e,n);if(t.x>0)u=o(this.right,e,n);if(u&&i(u.y,this.top,this.bottom))return u;a=Math.abs(e.x-this.left)<Math.abs(e.x-this.right)?this.left:this.right;f=Math.abs(e.y-this.top)<Math.abs(e.y-this.bottom)?this.top:this.bottom;return a<f?r(a,e.y):r(e.x,f)}},{"./vector":14}],6:[function(e,t,n){var r=e("./body");var i=e("./simulation");var s=e("./boundary");var o=e("./animation");var u=t.exports=o({defaultOptions:{deceleration:400},onStart:function(e,t,n,o,u,a){var f=n.sub(t).normalize(),l=f.mult(o.deceleration).negate(),c=s({left:Math.min(n.x,t.x),right:Math.max(n.x,t.x),top:Math.min(n.y,t.y),bottom:Math.max(n.y,t.y)});e=f.mult(e.norm());this._body=r(e,t,{accelerate:function(e,t){return l},update:function(e,t){if(!f.directionEqual(t)){u.cancel(e,{x:0,y:0})}else if(c.contains(e)){u.state(e,t)}else{u.done(n,t)}}});i.addBody(this._body)},onEnd:function(){i.removeBody(this._body)}})},{"./animation":2,"./body":4,"./boundary":5,"./simulation":11}],7:[function(e,t,n){function o(e,t,n){var r;this._phys=e;if(typeof t==="function"){this._startFn=t;t={}}else{this._startFn=n}this._opts=i({},s,t);if(this._opts.boundry){console.warn("Warning: Misspelled option 'boundry' is being deprecated. Please use 'boundary' instead.");this._opts.boundary=this._opts.boundry;delete this._opts.boundry}r=this._opts.handle;if(r&&!r.length){r=[r]}else if(r&&r.length){r=[].slice.call(r)}else{r=e.els}r.forEach(this._setupHandle,this)}var r=e("component-emitter"),i=e("lodash.defaults");var s={};t.exports=o;r(o.prototype);o.prototype.moved=function(){return this._interaction.distance()>10};o.prototype._setupHandle=function(e){e.addEventListener("touchstart",this._start.bind(this));e.addEventListener("mousedown",this._start.bind(this));e.addEventListener("touchmove",this._move.bind(this));window.addEventListener("mousemove",this._move.bind(this));e.addEventListener("touchend",this._end.bind(this));window.addEventListener("mouseup",this._end.bind(this))};o.prototype._start=function(e){this._startTime=Date.now();e.preventDefault();this._mousedown=true;this._interaction=this._phys.interact({boundary:this._opts.boundary,damping:this._opts.damping,direction:this._opts.direction});var t=this._interaction.start(e);this._startFn&&this._startFn(t);this.emit("start",e)};o.prototype._move=function(e){if(!this._mousedown)return;e.preventDefault();this._interaction.update(e);this.emit("move",e)};o.prototype._end=function(e){if(!this._mousedown)return;e.preventDefault();this._mousedown=false;this._interaction.end();this.emit("end",e)}},{"component-emitter":16,"lodash.defaults":17}],8:[function(e,t,n){function v(e){if(!(this instanceof v)){return new v(e)}if(typeof e==="function"){this._render=e;this.els=[]}else{if(e.length)this.els=[].slice.call(e);else this.els=[e];this._renderer=new s(this.els);this._render=this._renderer.update.bind(this._renderer)}this._position=i(0,0);this._velocity=i(0,0)}var r=e("./simulation");var i=e("./vector");var s=e("./renderer");var o=e("lodash.defaults");var u=e("./spring");var a=e("./attach-spring");var f=e("./decelerate");var l=e("./accelerate");var c=e("./drag");var h=e("./interact");var p=e("./boundary");var d=window.Promise||e("promise");t.exports=v;v.Boundary=p;v.Boundry=p;v.Vector=i;v.Promise=d;v.prototype.style=function(){this._renderer.style.apply(this._renderer,arguments);return this};v.prototype.visible=function(){this._renderer.visible.apply(this._renderer,arguments);return this};v.prototype.direction=function(e){var t=this.velocity(),n,r,i;if(t.x<0)n="left";else if(t.x>0)n="right";if(t.y<0)r="up";else if(t.y>0)r="down";var i=n+(r||"").toUpperCase();return e===n||e===r||e===i};v.prototype.forceRender=function(){if(this._renderer){this._renderer.changed=true}};v.prototype.atRest=function(){var e=this.velocity();return e.x===0&&e.y===0};v.prototype._startAnimation=function(e){if(this._currentAnimation&&this._currentAnimation.running()){this._currentAnimation.cancel()}this._currentAnimation=e};v.prototype.velocity=function(e,t){if(!arguments.length)return this._velocity;this._velocity=i(e,t);return this};v.prototype.position=function(e,t){if(!arguments.length)return this._position.clone();this._position=i(e,t);this._render(this._position.x,this._position.y);return this};v.prototype.interact=function(e){return new h(this,e)};v.prototype.drag=function(e,t){return new c(this,e,t)};v.prototype.spring=function(e){return new u(this,e)};v.prototype.decelerate=function(e){return new f(this,e)};v.prototype.accelerate=function(e){return new l(this,e)};v.prototype.attachSpring=function(e,t){return new a(this,e,t)}},{"./accelerate":1,"./attach-spring":3,"./boundary":5,"./decelerate":6,"./drag":7,"./interact":9,"./renderer":10,"./simulation":11,"./spring":12,"./vector":14,"lodash.defaults":17,promise:24}],9:[function(e,t,n){function l(e,t){this._phys=e;this._running=false;this._opts=r({},t,f);if(this._opts.boundry){console.warn("Warning: Misspelled option 'boundry' is being deprecated. Please use 'boundary' instead.");this._opts.boundary=this._opts.boundry;delete this._opts.boundry}}var r=e("lodash.defaults");var i=e("touch-velocity");var s=e("./vector");var o=e("promise");var u=e("./util");var a=e("./boundary");t.exports=l;var f={boundary:a({}),damping:0,direction:"both"};l.prototype.position=function(e,t){var n=this._opts.direction,r=this._opts.boundary,i=s(e,t);if(n!=="both"&&n!=="horizontal")i.x=0;if(n!=="both"&&n!=="vertical")i.y=0;this._veloX.updatePosition(i.x);this._veloY.updatePosition(i.y);this._phys.velocity(this._veloX.getVelocity(),this._veloY.getVelocity());i=r.applyDamping(i,this._opts.damping);this._phys.position(i);return this};l.prototype.update=function(e){e=e.originalEvent||e;var t=u.eventVector(e).sub(this._startPosition);this.position(t);return this};l.prototype.start=function(e){var t=this,n=e&&u.eventVector(e),r=this._phys.position();this._running=true;this._phys._startAnimation(this);this._startPosition=e&&n.sub(r);this._initialPosition=this._phys.position();this._veloX=new i;this._veloY=new i;this.position(r);return this._ended=new o(function(e,n){t._resolve=e;t._reject=n})};l.prototype.distance=function(){return this._initialPosition.sub(this._phys.position()).norm()};l.prototype.cancel=function(){this._running=false;this._reject(new Error("Canceled the interaction"))};l.prototype.running=function(){return this._running};l.prototype.end=function(){this._phys.velocity(this._veloX.getVelocity(),this._veloY.getVelocity());this._resolve({velocity:this._phys.velocity(),position:this._phys.position()});return this._ended}},{"./boundary":5,"./util":13,"./vector":14,"lodash.defaults":17,promise:24,"touch-velocity":28}],10:[function(e,t,n){function a(){o(function(){a();for(var e=i.length-1;e>=0;e--){i[e]()}})}function f(e){var t;for(var n=0;n<r.length;n++){t=r[n]+e[0].toUpperCase()+e.slice(1);if(typeof document.body.style[t]!=="undefined")return t}return e}function c(e){if(typeof e.length==="undefined")e=[e];this.els=e;this.styles={};this.invisibleEls=[];this.changed=false;i.push(this.render.bind(this))}var r=["Webkit","Moz","Ms","ms"];var i=[];var s;var o=e("raf");var u=e("./util").floatEqual;a();var l=["translate","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotate3d","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","skewZ"];t.exports=c;c.prototype.render=function(){if(!this.changed)return;if(!s)s=f("transform");var e,t=this.els,n=this.currentPosition,r=this.styles,i,o=Object.keys(r),u=t.length,a=o.length,c,h,p;this.changed=false;for(c=0;c<u;c++){e=[];if(this.visibleFn&&!this.visibleFn(n,c)){if(!this.invisibleEls[c]){t[c].style.webkitTransform="translate3d(0, -99999px, 0)"}this.invisibleEls[c]=true}else{this.invisibleEls[c]=false;for(h=0;h<a;h++){prop=o[h];i=typeof r[prop]==="function"?r[prop](n.x,n.y,c):r[prop];if(l.indexOf(prop)!==-1){e.push(prop+"("+i+")")}else{t[c].style[prop]=i}}p=e.join(" ");p+=" translateZ(0)";t[c].style[s]=p}}};c.prototype.style=function(e,t){if(typeof e==="object"){for(prop in e){if(e.hasOwnProperty(prop)){this.style(prop,e[prop])}}}this.styles[e]=t;return this};c.prototype.visible=function(e){this.visibleFn=e;return this};c.prototype.update=function(e,t){if(this.currentPosition){var n=u(e,this.currentPosition.x)&&u(t,this.currentPosition.y);this.changed=this.changed||!n}else{this.changed=true}this.currentPosition={x:e,y:t}}},{"./util":13,raf:26}],11:[function(e,t,n){function o(e,t,n,i){var s=r(0,0);s.selfAdd(e);s.selfAdd(t.add(n).selfMult(2));s.selfAdd(i);s.selfMult(1/6);return s}function f(e,t,n,r){var i={};i.position=u.setv(r.dx).selfMult(n).selfAdd(e.position);i.velocity=a.setv(r.dv).selfMult(n).selfAdd(e.velocity);var s={dx:i.velocity.clone(),dv:e.accelerate(i,t).clone()};return s}function c(e,t,n){var r=f(e,t,0,l);var i=f(e,t,n*.5,r);var s=f(e,t,n*.5,i);var u=f(e,t,n,s);var a=o(r.dx,i.dx,s.dx,u.dx),c=o(r.dv,i.dv,s.dv,u.dv);e.position.selfAdd(a.selfMult(n));e.velocity.selfAdd(c.selfMult(n))}function m(){s(function(){m();var e=Date.now()/1e3;var t=e-h;h=e;if(t>.05)t=.05;p+=t;var n=0;while(p>=v){for(var r=0;r<i.length;r++){i[r].previousPosition=i[r].position.clone();c(i[r],d,v)}d+=v;p-=v}for(var r=0;r<i.length;r++){i[r].update(p/v)}},16)}var r=e("./vector"),i=[],s=e("raf");var u=r(0,0);var a=r(0,0);var l={dx:r(0,0),dv:r(0,0)};var h=Date.now()/1e3,p=0,d=0,v=.015;m();t.exports.addBody=function(e){i.push(e);return e};t.exports.removeBody=function(e){var t=i.indexOf(e);if(t>=0)i.splice(t,1)}},{"./vector":14,raf:26}],12:[function(e,t,n){var r=e("./body");var i=e("./simulation");var s=e("./boundary");var o=e("./animation");var u=t.exports=o({defaultOptions:{tension:100,damping:10},onStart:function(e,t,n,s,o){var u=this._body=new r(e,t,{accelerate:function(e,t){return e.position.selfSub(n).selfMult(-s.tension).selfSub(e.velocity.mult(s.damping))},update:function(e,t){if(u.atRest()&&u.atPosition(n)){o.done(n,{x:0,y:0})}else{o.state(e,t)}}});i.addBody(this._body)},onEnd:function(){i.removeBody(this._body)}})},{"./animation":2,"./body":4,"./boundary":5,"./simulation":11}],13:[function(e,t,n){function i(e,t){return-t/(2*e)}function s(e,t,n){return o(e,t,n,i(e,t))}function o(e,t,n,r){return e*r*r+t*r+n}function u(e){return r({x:e.touches&&e.touches[0].pageX||e.pageX,y:e.touches&&e.touches[0].pageY||e.pageY})}function a(e,t){return Math.abs(e-t)<Number.EPSILON}var r=e("./vector");t.exports.height=s;t.exports.eventVector=u;t.exports.floatEqual=a},{"./vector":14}],14:[function(e,t,n){function r(e,t){if(!(this instanceof r))return new r(e,t);if(typeof e.x!=="undefined"){this.x=e.x;this.y=e.y}else{this.x=e||0;this.y=t||0}}t.exports=r;r.prototype.equals=function(e){return e.x===this.x&&e.y===this.y};r.prototype.directionEqual=function(e){return e.x>0===this.x>0&&this.y>0===e.y>0};r.prototype.dot=function(e){return this.x*e.x+this.y*e.y};r.prototype.negate=function(){return r(this.x,this.y).mult(-1)};r.prototype.norm=function(){return Math.sqrt(this.normsq())};r.prototype.clone=function(){return r(this.x,this.y)};r.prototype.normsq=function(){return this.x*this.x+this.y*this.y};r.prototype.normalize=function(){var e=this.norm();if(e===0){return this}e=1/e;this.x*=e;this.y*=e;return this};r.prototype.mult=function(e,t){if(e instanceof r){return new r(e.x*this.x,e.y*this.y)}if(typeof t==="undefined"){return new r(e*this.x,e*this.y)}return new r(e*this.x,t*this.y)};r.prototype.selfMult=function(e,t){if(e instanceof r){this.x*=e.x;this.y*=e.y;return this}if(typeof t==="undefined"){this.x*=e;this.y*=e;return this}this.x*=e;this.y*=t;return this};r.prototype.selfAdd=function(e,t){if(typeof e.x!=="undefined"){this.x+=e.x;this.y+=e.y;return this}if(typeof t==="undefined"){this.x+=e;this.y+=e;return this}this.x+=e;this.y+=t;return this};r.prototype.selfSub=function(e,t){if(typeof e.x!=="undefined"){this.x-=e.x;this.y-=e.y;return this}if(typeof t==="undefined"){this.x-=e;this.y-=e;return this}this.x-=e;this.y-=t;return this};r.prototype.sub=function(e,t){if(typeof e.x!=="undefined")return new r(this.x-e.x,this.y-e.y);if(typeof t==="undefined")return new r(this.x-e,this.y-e);return new r(this.x-e,this.y-t)};r.prototype.add=function(e,t){if(typeof e.x!=="undefined"){return new r(this.x+e.x,this.y+e.y)}if(typeof t==="undefined"){return new r(this.x+e,this.y+e)}return new r(this.x+e,this.y+t)};r.prototype.setv=function(e){this.x=e.x;this.y=e.y;return this};r.prototype.lerp=function(e,t){return this.mult(1-t).add(e.mult(t))}},{}],15:[function(e,t,n){function i(){}var r=t.exports={};r.nextTick=function(){var e=typeof window!=="undefined"&&window.setImmediate;var t=typeof window!=="undefined"&&window.MutationObserver;var n=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(e){return function(e){return window.setImmediate(e)}}var r=[];if(t){var i=document.createElement("div");var s=new MutationObserver(function(){var e=r.slice();r.length=0;e.forEach(function(e){e()})});s.observe(i,{attributes:true});return function(t){if(!r.length){i.setAttribute("yes","no")}r.push(t)}}if(n){window.addEventListener("message",function(e){var t=e.source;if((t===window||t===null)&&e.data==="process-tick"){e.stopPropagation();if(r.length>0){var n=r.shift();n()}}},true);return function(t){r.push(t);window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}();r.title="browser";r.browser=true;r.env={};r.argv=[];r.on=i;r.addListener=i;r.once=i;r.off=i;r.removeListener=i;r.removeAllListeners=i;r.emit=i;r.binding=function(e){throw new Error("process.binding is not supported")};r.cwd=function(){return"/"};r.chdir=function(e){throw new Error("process.chdir is not supported")}},{}],16:[function(e,t,n){function r(e){if(e)return i(e)}function i(e){for(var t in r.prototype){e[t]=r.prototype[t]}return e}t.exports=r;r.prototype.on=r.prototype.addEventListener=function(e,t){this._callbacks=this._callbacks||{};(this._callbacks[e]=this._callbacks[e]||[]).push(t);return this};r.prototype.once=function(e,t){function r(){n.off(e,r);t.apply(this,arguments)}var n=this;this._callbacks=this._callbacks||{};r.fn=t;this.on(e,r);return this};r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(e,t){this._callbacks=this._callbacks||{};if(0==arguments.length){this._callbacks={};return this}var n=this._callbacks[e];if(!n)return this;if(1==arguments.length){delete this._callbacks[e];return this}var r;for(var i=0;i<n.length;i++){r=n[i];if(r===t||r.fn===t){n.splice(i,1);break}}return this};r.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks[e];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r){n[r].apply(this,t)}}return this};r.prototype.listeners=function(e){this._callbacks=this._callbacks||{};return this._callbacks[e]||[]};r.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],17:[function(e,t,n){var r=e("lodash.keys"),i=e("lodash._objecttypes");var s=function(e,t,n){var s,o=e,u=o;if(!o)return u;var a=arguments,f=0,l=typeof n=="number"?2:a.length;while(++f<l){o=a[f];if(o&&i[typeof o]){var c=-1,h=i[typeof o]&&r(o),p=h?h.length:0;while(++c<p){s=h[c];if(typeof u[s]=="undefined")u[s]=o[s]}}}return u};t.exports=s},{"lodash._objecttypes":18,"lodash.keys":19}],18:[function(e,t,n){var r={"boolean":false,"function":true,object:true,number:false,string:false,"undefined":false};t.exports=r},{}],19:[function(e,t,n){var r=e("lodash._isnative"),i=e("lodash.isobject"),s=e("lodash._shimkeys");var o=r(o=Object.keys)&&o;var u=!o?s:function(e){if(!i(e)){return[]}return o(e)};t.exports=u},{"lodash._isnative":20,"lodash._shimkeys":21,"lodash.isobject":22}],20:[function(e,t,n){function o(e){return typeof e=="function"&&s.test(e)}var r=Object.prototype;var i=r.toString;var s=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");t.exports=o},{}],21:[function(e,t,n){var r=e("lodash._objecttypes");var i=Object.prototype;var s=i.hasOwnProperty;var o=function(e){var t,n=e,i=[];if(!n)return i;if(!r[typeof e])return i;for(t in n){if(s.call(n,t)){i.push(t)}}return i};t.exports=o},{"lodash._objecttypes":18}],22:[function(e,t,n){function i(e){return!!(e&&r[typeof e])}var r=e("lodash._objecttypes");t.exports=i},{"lodash._objecttypes":18}],23:[function(e,t,n){"use strict";function i(e){function f(e){if(t===null){u.push(e);return}r(function(){var r=t?e.onFulfilled:e.onRejected;if(r===null){(t?e.resolve:e.reject)(n);return}var i;try{i=r(n)}catch(s){e.reject(s);return}e.resolve(i)})}function l(e){try{if(e===a)throw new TypeError("A promise cannot be resolved with itself.");if(e&&(typeof e==="object"||typeof e==="function")){var r=e.then;if(typeof r==="function"){o(r.bind(e),l,c);return}}t=true;n=e;h()}catch(i){c(i)}}function c(e){t=false;n=e;h()}function h(){for(var e=0,t=u.length;e<t;e++)f(u[e]);u=null}if(typeof this!=="object")throw new TypeError("Promises must be constructed via new");if(typeof e!=="function")throw new TypeError("not a function");var t=null;var n=null;var u=[];var a=this;this.then=function(e,t){return new i(function(n,r){f(new s(e,t,n,r))})};o(e,l,c)}function s(e,t,n,r){this.onFulfilled=typeof e==="function"?e:null;this.onRejected=typeof t==="function"?t:null;this.resolve=n;this.reject=r}function o(e,t,n){var r=false;try{e(function(e){if(r)return;r=true;t(e)},function(e){if(r)return;r=true;n(e)})}catch(i){if(r)return;r=true;n(i)}}var r=e("asap");t.exports=i},{asap:25}],24:[function(e,t,n){"use strict";function s(e){this.then=function(t){if(typeof t!=="function")return this;return new r(function(n,r){i(function(){try{n(t(e))}catch(i){r(i)}})})}}var r=e("./core.js");var i=e("asap");t.exports=r;s.prototype=Object.create(r.prototype);var o=new s(true);var u=new s(false);var a=new s(null);var f=new s(undefined);var l=new s(0);var c=new s("");r.resolve=function(e){if(e instanceof r)return e;if(e===null)return a;if(e===undefined)return f;if(e===true)return o;if(e===false)return u;if(e===0)return l;if(e==="")return c;if(typeof e==="object"||typeof e==="function"){try{var t=e.then;if(typeof t==="function"){return new r(t.bind(e))}}catch(n){return new r(function(e,t){t(n)})}}return new s(e)};r.from=r.cast=function(e){var t=new Error("Promise.from and Promise.cast are deprecated, use Promise.resolve instead");t.name="Warning";console.warn(t.stack);return r.resolve(e)};r.denodeify=function(e,t){t=t||Infinity;return function(){var n=this;var i=Array.prototype.slice.call(arguments);return new r(function(r,s){while(i.length&&i.length>t){i.pop()}i.push(function(e,t){if(e)s(e);else r(t)});e.apply(n,i)})}};r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments);var n=typeof t[t.length-1]==="function"?t.pop():null;try{return e.apply(this,arguments).nodeify(n)}catch(s){if(n===null||typeof n=="undefined"){return new r(function(e,t){t(s)})}else{i(function(){n(s)})}}}};r.all=function(){var e=arguments.length===1&&Array.isArray(arguments[0]);var t=Array.prototype.slice.call(e?arguments[0]:arguments);if(!e){var n=new Error("Promise.all should be called with a single array, calling it with multiple arguments is deprecated");n.name="Warning";console.warn(n.stack)}return new r(function(e,n){function i(s,o){try{if(o&&(typeof o==="object"||typeof o==="function")){var u=o.then;if(typeof u==="function"){u.call(o,function(e){i(s,e)},n);return}}t[s]=o;if(--r===0){e(t)}}catch(a){n(a)}}if(t.length===0)return e([]);var r=t.length;for(var s=0;s<t.length;s++){i(s,t[s])}})};r.reject=function(e){return new r(function(t,n){n(e)})};r.race=function(e){return new r(function(t,n){e.forEach(function(e){r.resolve(e).then(t,n)})})};r.prototype.done=function(e,t){var n=arguments.length?this.then.apply(this,arguments):this;n.then(null,function(e){i(function(){throw e})})};r.prototype.nodeify=function(e){if(typeof e!="function")return this;this.then(function(t){i(function(){e(null,t)})},function(t){i(function(){e(t)})})};r.prototype["catch"]=function(e){return this.then(null,e)}},{"./core.js":23,asap:25}],25:[function(e,t,n){(function(e){function u(){while(n.next){n=n.next;var e=n.task;n.task=void 0;var t=n.domain;if(t){n.domain=void 0;t.enter()}try{e()}catch(r){if(o){if(t){t.exit()}setTimeout(u,0);if(t){t.enter()}throw r}else{setTimeout(function(){throw r},0)}}if(t){t.exit()}}i=false}function f(t){r=r.next={task:t,domain:o&&e.domain,next:null};if(!i){i=true;s()}}var n={task:void 0,next:null};var r=n;var i=false;var s=void 0;var o=false;if(typeof e!=="undefined"&&e.nextTick){o=true;s=function(){e.nextTick(u)}}else if(typeof setImmediate==="function"){if(typeof window!=="undefined"){s=setImmediate.bind(window,u)}else{s=function(){setImmediate(u)}}}else if(typeof MessageChannel!=="undefined"){var a=new MessageChannel;a.port1.onmessage=u;s=function(){a.port2.postMessage(0)}}else{s=function(){setTimeout(u,0)}}t.exports=f}).call(this,e("_process"))},{_process:15}],26:[function(e,t,n){var r=e("performance-now"),i=typeof window==="undefined"?{}:window,s=["moz","webkit"],o="AnimationFrame",u=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],f=true;for(var l=0;l<s.length&&!u;l++){u=i[s[l]+"Request"+o];a=i[s[l]+"Cancel"+o]||i[s[l]+"CancelRequest"+o]}if(!u||!a){f=false;var c=0,h=0,p=[],d=1e3/60;u=function(e){if(p.length===0){var t=r(),n=Math.max(0,d-(t-c));c=n+t;setTimeout(function(){var e=p.slice(0);p.length=0;for(var t=0;t<e.length;t++){if(!e[t].cancelled){try{e[t].callback(c)}catch(n){setTimeout(function(){throw n},0)}}}},Math.round(n))}p.push({handle:++h,callback:e,cancelled:false});return h};a=function(e){for(var t=0;t<p.length;t++){if(p[t].handle===e){p[t].cancelled=true}}}}t.exports=function(e){if(!f){return u.call(i,e)}return u.call(i,function(){try{e.apply(this,arguments)}catch(t){setTimeout(function(){throw t},0)}})};t.exports.cancel=function(){a.apply(i,arguments)}},{"performance-now":27}],27:[function(e,t,n){(function(e){(function(){var n,r,i;if(typeof performance!=="undefined"&&performance!==null&&performance.now){t.exports=function(){return performance.now()}}else if(typeof e!=="undefined"&&e!==null&&e.hrtime){t.exports=function(){return(n()-i)/1e6};r=e.hrtime;n=function(){var e;e=r();return e[0]*1e9+e[1]};i=n()}else if(Date.now){t.exports=function(){return Date.now()-i};i=Date.now()}else{t.exports=function(){return(new Date).getTime()-i};i=(new Date).getTime()}}).call(this)}).call(this,e("_process"))},{_process:15}],28:[function(e,t,n){function r(){this.positionQueue=[];this.timeQueue=[]}t.exports=r;r.prototype.reset=function(){this.positionQueue.splice(0);this.timeQueue.splice(0)};r.prototype.pruneQueue=function(e){while(this.timeQueue.length&&this.timeQueue[0]<Date.now()-e){this.timeQueue.shift();this.positionQueue.shift()}};r.prototype.updatePosition=function(e){this.positionQueue.push(e);this.timeQueue.push(Date.now());this.pruneQueue(50)};r.prototype.getVelocity=function(){this.pruneQueue(1e3);var e=this.timeQueue.length;if(e<2)return 0;var t=this.positionQueue[e-1]-this.positionQueue[0],n=(this.timeQueue[e-1]-this.timeQueue[0])/1e3;return t/n}},{}]},{},[8])(8)})
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: impulse-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sherwyn Goh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ description: Currently for Impulse version 0.1.0
56
+ email:
57
+ - sherwyn.lj.goh@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - impulse-rails.gemspec
68
+ - lib/impulse-rails.rb
69
+ - vendor/assets/javascripts/impulse.js
70
+ homepage: ''
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.4.5
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Impulse Js for the rails 3.1+ asset pipeline
94
+ test_files: []