50 lines
No EOL
175 KiB
JavaScript
50 lines
No EOL
175 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* Owner: mark@famo.us
|
|
* @license MPL 2.0
|
|
* @copyright Famous Industries, Inc. 2014
|
|
*/
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* Owner: david@famo.us
|
|
* @license MPL 2.0
|
|
* @copyright Famous Industries, Inc. 2014
|
|
*/
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* @license MPL 2.0
|
|
* @copyright Famous Industries, Inc. 2014
|
|
*/
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* Owner: mike@famo.us
|
|
* @license MPL 2.0
|
|
* @copyright Famous Industries, Inc. 2014
|
|
*/
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* Owner: felix@famo.us
|
|
* @license MPL 2.0
|
|
* @copyright Famous Industries, Inc. 2014
|
|
*/
|
|
|
|
define("famous/core/Entity",["require","exports","module"],function(t,i,e){function s(t){return a[t]}function o(t,i){a[t]=i}function n(t){var i=a.length;return o(i,t),i}function r(t){o(t,null)}var a=[];e.exports={register:n,unregister:r,get:s,set:o}}),define("famous/core/Transform",["require","exports","module"],function(t,i,e){function s(t){return 2===t.length?t[0]*t[0]+t[1]*t[1]:t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function o(t){return Math.sqrt(s(t))}function n(t){return 0>t?-1:1}var r={};r.precision=1e-6,r.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.multiply4x4=function(t,i){return[t[0]*i[0]+t[4]*i[1]+t[8]*i[2]+t[12]*i[3],t[1]*i[0]+t[5]*i[1]+t[9]*i[2]+t[13]*i[3],t[2]*i[0]+t[6]*i[1]+t[10]*i[2]+t[14]*i[3],t[3]*i[0]+t[7]*i[1]+t[11]*i[2]+t[15]*i[3],t[0]*i[4]+t[4]*i[5]+t[8]*i[6]+t[12]*i[7],t[1]*i[4]+t[5]*i[5]+t[9]*i[6]+t[13]*i[7],t[2]*i[4]+t[6]*i[5]+t[10]*i[6]+t[14]*i[7],t[3]*i[4]+t[7]*i[5]+t[11]*i[6]+t[15]*i[7],t[0]*i[8]+t[4]*i[9]+t[8]*i[10]+t[12]*i[11],t[1]*i[8]+t[5]*i[9]+t[9]*i[10]+t[13]*i[11],t[2]*i[8]+t[6]*i[9]+t[10]*i[10]+t[14]*i[11],t[3]*i[8]+t[7]*i[9]+t[11]*i[10]+t[15]*i[11],t[0]*i[12]+t[4]*i[13]+t[8]*i[14]+t[12]*i[15],t[1]*i[12]+t[5]*i[13]+t[9]*i[14]+t[13]*i[15],t[2]*i[12]+t[6]*i[13]+t[10]*i[14]+t[14]*i[15],t[3]*i[12]+t[7]*i[13]+t[11]*i[14]+t[15]*i[15]]},r.multiply=function(t,i){return[t[0]*i[0]+t[4]*i[1]+t[8]*i[2],t[1]*i[0]+t[5]*i[1]+t[9]*i[2],t[2]*i[0]+t[6]*i[1]+t[10]*i[2],0,t[0]*i[4]+t[4]*i[5]+t[8]*i[6],t[1]*i[4]+t[5]*i[5]+t[9]*i[6],t[2]*i[4]+t[6]*i[5]+t[10]*i[6],0,t[0]*i[8]+t[4]*i[9]+t[8]*i[10],t[1]*i[8]+t[5]*i[9]+t[9]*i[10],t[2]*i[8]+t[6]*i[9]+t[10]*i[10],0,t[0]*i[12]+t[4]*i[13]+t[8]*i[14]+t[12],t[1]*i[12]+t[5]*i[13]+t[9]*i[14]+t[13],t[2]*i[12]+t[6]*i[13]+t[10]*i[14]+t[14],1]},r.thenMove=function(t,i){return i[2]||(i[2]=0),[t[0],t[1],t[2],0,t[4],t[5],t[6],0,t[8],t[9],t[10],0,t[12]+i[0],t[13]+i[1],t[14]+i[2],1]},r.moveThen=function(t,i){t[2]||(t[2]=0);var e=t[0]*i[0]+t[1]*i[4]+t[2]*i[8],s=t[0]*i[1]+t[1]*i[5]+t[2]*i[9],o=t[0]*i[2]+t[1]*i[6]+t[2]*i[10];return r.thenMove(i,[e,s,o])},r.translate=function(t,i,e){return void 0===e&&(e=0),[1,0,0,0,0,1,0,0,0,0,1,0,t,i,e,1]},r.thenScale=function(t,i){return[i[0]*t[0],i[1]*t[1],i[2]*t[2],0,i[0]*t[4],i[1]*t[5],i[2]*t[6],0,i[0]*t[8],i[1]*t[9],i[2]*t[10],0,i[0]*t[12],i[1]*t[13],i[2]*t[14],1]},r.scale=function(t,i,e){return void 0===e&&(e=1),[t,0,0,0,0,i,0,0,0,0,e,0,0,0,0,1]},r.rotateX=function(t){var i=Math.cos(t),e=Math.sin(t);return[1,0,0,0,0,i,e,0,0,-e,i,0,0,0,0,1]},r.rotateY=function(t){var i=Math.cos(t),e=Math.sin(t);return[i,0,-e,0,0,1,0,0,e,0,i,0,0,0,0,1]},r.rotateZ=function(t){var i=Math.cos(t),e=Math.sin(t);return[i,e,0,0,-e,i,0,0,0,0,1,0,0,0,0,1]},r.rotate=function(t,i,e){var s=Math.cos(t),o=Math.sin(t),n=Math.cos(i),r=Math.sin(i),a=Math.cos(e),h=Math.sin(e),u=[n*a,s*h+o*r*a,o*h-s*r*a,0,-n*h,s*a-o*r*h,o*a+s*r*h,0,r,-o*n,s*n,0,0,0,0,1];return u},r.rotateAxis=function(t,i){var e=Math.sin(i),s=Math.cos(i),o=1-s,n=t[0]*t[0]*o,r=t[0]*t[1]*o,a=t[0]*t[2]*o,h=t[1]*t[1]*o,u=t[1]*t[2]*o,c=t[2]*t[2]*o,p=t[0]*e,l=t[1]*e,f=t[2]*e,d=[n+s,r+f,a-l,0,r-f,h+s,u+p,0,a+l,u-p,c+s,0,0,0,0,1];return d},r.aboutOrigin=function(t,i){var e=t[0]-(t[0]*i[0]+t[1]*i[4]+t[2]*i[8]),s=t[1]-(t[0]*i[1]+t[1]*i[5]+t[2]*i[9]),o=t[2]-(t[0]*i[2]+t[1]*i[6]+t[2]*i[10]);return r.thenMove(i,[e,s,o])},r.skew=function(t,i,e){return[1,0,0,0,Math.tan(e),1,0,0,Math.tan(i),Math.tan(t),1,0,0,0,0,1]},r.skewX=function(t){return[1,0,0,0,Math.tan(t),1,0,0,0,0,1,0,0,0,0,1]},r.skewY=function(t){return[1,Math.tan(t),0,0,0,1,0,0,0,0,1,0,0,0,0,1]},r.perspective=function(t){return[1,0,0,0,0,1,0,0,0,0,1,-1/t,0,0,0,1]},r.getTranslate=function(t){return[t[12],t[13],t[14]]},r.inverse=function(t){var i=t[5]*t[10]-t[6]*t[9],e=t[4]*t[10]-t[6]*t[8],s=t[4]*t[9]-t[5]*t[8],o=t[1]*t[10]-t[2]*t[9],n=t[0]*t[10]-t[2]*t[8],r=t[0]*t[9]-t[1]*t[8],a=t[1]*t[6]-t[2]*t[5],h=t[0]*t[6]-t[2]*t[4],u=t[0]*t[5]-t[1]*t[4],c=t[0]*i-t[1]*e+t[2]*s,p=1/c,l=[p*i,-p*o,p*a,0,-p*e,p*n,-p*h,0,p*s,-p*r,p*u,0,0,0,0,1];return l[12]=-t[12]*l[0]-t[13]*l[4]-t[14]*l[8],l[13]=-t[12]*l[1]-t[13]*l[5]-t[14]*l[9],l[14]=-t[12]*l[2]-t[13]*l[6]-t[14]*l[10],l},r.transpose=function(t){return[t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]]},r.interpret=function(t){var i=[t[0],t[1],t[2]],e=n(i[0]),a=o(i),h=[i[0]+e*a,i[1],i[2]],u=2/s(h);if(u>=1/0)return{translate:r.getTranslate(t),rotate:[0,0,0],scale:[0,0,0],skew:[0,0,0]};var c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];c[0]=1-u*h[0]*h[0],c[5]=1-u*h[1]*h[1],c[10]=1-u*h[2]*h[2],c[1]=-u*h[0]*h[1],c[2]=-u*h[0]*h[2],c[6]=-u*h[1]*h[2],c[4]=c[1],c[8]=c[2],c[9]=c[6];var p=r.multiply(c,t),l=[p[5],p[6]],f=n(l[0]),d=o(l),m=[l[0]+f*d,l[1]],y=2/s(m),_=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];_[5]=1-y*m[0]*m[0],_[10]=1-y*m[1]*m[1],_[6]=-y*m[0]*m[1],_[9]=_[6];var g=r.multiply(_,c),v=r.multiply(g,t),O=r.scale(v[0]<0?-1:1,v[5]<0?-1:1,v[10]<0?-1:1);v=r.multiply(v,O),g=r.multiply(O,g);var T={};return T.translate=r.getTranslate(t),T.rotate=[Math.atan2(-g[6],g[10]),Math.asin(g[2]),Math.atan2(-g[1],g[0])],T.rotate[0]||(T.rotate[0]=0,T.rotate[2]=Math.atan2(g[4],g[5])),T.scale=[v[0],v[5],v[10]],T.skew=[Math.atan2(v[9],T.scale[2]),Math.atan2(v[8],T.scale[2]),Math.atan2(v[4],T.scale[0])],Math.abs(T.rotate[0])+Math.abs(T.rotate[2])>1.5*Math.PI&&(T.rotate[1]=Math.PI-T.rotate[1],T.rotate[1]>Math.PI&&(T.rotate[1]-=2*Math.PI),T.rotate[1]<-Math.PI&&(T.rotate[1]+=2*Math.PI),T.rotate[0]<0?T.rotate[0]+=Math.PI:T.rotate[0]-=Math.PI,T.rotate[2]<0?T.rotate[2]+=Math.PI:T.rotate[2]-=Math.PI),T},r.average=function(t,i,e){e=void 0===e?.5:e;for(var s=r.interpret(t),o=r.interpret(i),n={translate:[0,0,0],rotate:[0,0,0],scale:[0,0,0],skew:[0,0,0]},a=0;3>a;a++)n.translate[a]=(1-e)*s.translate[a]+e*o.translate[a],n.rotate[a]=(1-e)*s.rotate[a]+e*o.rotate[a],n.scale[a]=(1-e)*s.scale[a]+e*o.scale[a],n.skew[a]=(1-e)*s.skew[a]+e*o.skew[a];return r.build(n)},r.build=function(t){var i=r.scale(t.scale[0],t.scale[1],t.scale[2]),e=r.skew(t.skew[0],t.skew[1],t.skew[2]),s=r.rotate(t.rotate[0],t.rotate[1],t.rotate[2]);return r.thenMove(r.multiply(r.multiply(s,e),i),t.translate)},r.equals=function(t,i){return!r.notEquals(t,i)},r.notEquals=function(t,i){return t===i?!1:!(t&&i)||t[12]!==i[12]||t[13]!==i[13]||t[14]!==i[14]||t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[4]!==i[4]||t[5]!==i[5]||t[6]!==i[6]||t[8]!==i[8]||t[9]!==i[9]||t[10]!==i[10]},r.normalizeRotation=function(t){var i=t.slice(0);for((i[0]===.5*Math.PI||i[0]===.5*-Math.PI)&&(i[0]=-i[0],i[1]=Math.PI-i[1],i[2]-=Math.PI),i[0]>.5*Math.PI&&(i[0]=i[0]-Math.PI,i[1]=Math.PI-i[1],i[2]-=Math.PI),i[0]<.5*-Math.PI&&(i[0]=i[0]+Math.PI,i[1]=-Math.PI-i[1],i[2]-=Math.PI);i[1]<-Math.PI;)i[1]+=2*Math.PI;for(;i[1]>=Math.PI;)i[1]-=2*Math.PI;for(;i[2]<-Math.PI;)i[2]+=2*Math.PI;for(;i[2]>=Math.PI;)i[2]-=2*Math.PI;return i},r.inFront=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,.001,1],r.behind=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,-.001,1],e.exports=r}),define("famous/core/SpecParser",["require","exports","module","./Transform"],function(t,i,e){function s(){this.result={}}function o(t,i){return[t[0]*i[0]+t[1]*i[4]+t[2]*i[8],t[0]*i[1]+t[1]*i[5]+t[2]*i[9],t[0]*i[2]+t[1]*i[6]+t[2]*i[10]]}var n=t("./Transform");s._instance=new s,s.parse=function(t,i){return s._instance.parse(t,i)},s.prototype.parse=function(t,i){return this.reset(),this._parseSpec(t,i,n.identity),this.result},s.prototype.reset=function(){this.result={}};var r=[0,0];s.prototype._parseSpec=function(t,i,e){var s,a,h,u,c,p,l;if("number"==typeof t){if(s=t,h=i.transform,p=i.align||i.origin,i.size&&p&&(p[0]||p[1])){var f=[p[0]*i.size[0],p[1]*i.size[1],0];h=n.thenMove(h,o(f,e))}this.result[s]={transform:h,opacity:i.opacity,origin:i.origin||r,align:i.align||i.origin||r,size:i.size}}else{if(!t)return;if(t instanceof Array)for(var d=0;d<t.length;d++)this._parseSpec(t[d],i,e);else{a=t.target,h=i.transform,u=i.opacity,c=i.origin,p=i.align,l=i.size;var m=e;if(void 0!==t.opacity&&(u=i.opacity*t.opacity),t.transform&&(h=n.multiply(i.transform,t.transform)),t.origin&&(c=t.origin,m=i.transform),t.align&&(p=t.align),t.size){var y=i.size;l=[void 0!==t.size[0]?t.size[0]:y[0],void 0!==t.size[1]?t.size[1]:y[1]],y&&(p||(p=c),p&&(p[0]||p[1])&&(h=n.thenMove(h,o([p[0]*y[0],p[1]*y[1],0],e))),c&&(c[0]||c[1])&&(h=n.moveThen([-c[0]*l[0],-c[1]*l[1],0],h))),m=i.transform,c=null,p=null}this._parseSpec(a,{transform:h,opacity:u,origin:c,align:p,size:l},m)}}},e.exports=s}),define("famous/core/RenderNode",["require","exports","module","./Entity","./SpecParser"],function(t,i,e){function s(t){this._object=null,this._child=null,this._hasMultipleChildren=!1,this._isRenderable=!1,this._isModifier=!1,this._resultCache={},this._prevResults={},this._childResult=null,t&&this.set(t)}function o(t,i,e){for(var s=r.parse(t,i),a=Object.keys(s),h=0;h<a.length;h++){var u=a[h],c=n.get(u),p=s[u];p.allocator=i.allocator;var l=c.commit(p);l?o(l,i,e):e[u]=p}}var n=t("./Entity"),r=t("./SpecParser");s.prototype.add=function(t){var i=t instanceof s?t:new s(t);return this._child instanceof Array?this._child.push(i):this._child?(this._child=[this._child,i],this._hasMultipleChildren=!0,this._childResult=[]):this._child=i,i},s.prototype.get=function(){return this._object||(this._hasMultipleChildren?null:this._child?this._child.get():null)},s.prototype.set=function(t){return this._childResult=null,this._hasMultipleChildren=!1,this._isRenderable=t.render?!0:!1,this._isModifier=t.modify?!0:!1,this._object=t,this._child=null,t instanceof s?t:this},s.prototype.getSize=function(){var t=null,i=this.get();return i&&i.getSize&&(t=i.getSize()),!t&&this._child&&this._child.getSize&&(t=this._child.getSize()),t},s.prototype.commit=function(t){for(var i=Object.keys(this._prevResults),e=0;e<i.length;e++){var s=i[e];if(void 0===this._resultCache[s]){var r=n.get(s);r.cleanup&&r.cleanup(t.allocator)}}this._prevResults=this._resultCache,this._resultCache={},o(this.render(),t,this._resultCache)},s.prototype.render=function(){if(this._isRenderable)return this._object.render();var t=null;if(this._hasMultipleChildren){t=this._childResult;for(var i=this._child,e=0;e<i.length;e++)t[e]=i[e].render()}else this._child&&(t=this._child.render());return this._isModifier?this._object.modify(t):t},e.exports=s}),define("famous/core/EventEmitter",["require","exports","module"],function(t,i,e){function s(){this.listeners={},this._owner=this}s.prototype.emit=function(t,i){var e=this.listeners[t];if(e)for(var s=0;s<e.length;s++)e[s].call(this._owner,i);return this},s.prototype.on=function(t,i){t in this.listeners||(this.listeners[t]=[]);var e=this.listeners[t].indexOf(i);return 0>e&&this.listeners[t].push(i),this},s.prototype.addListener=s.prototype.on,s.prototype.removeListener=function(t,i){var e=this.listeners[t].indexOf(i);return e>=0&&this.listeners[t].splice(e,1),this},s.prototype.bindThis=function(t){this._owner=t},e.exports=s}),define("famous/core/EventHandler",["require","exports","module","./EventEmitter"],function(t,i,e){function s(){o.apply(this,arguments),this.downstream=[],this.downstreamFn=[],this.upstream=[],this.upstreamListeners={}}var o=t("./EventEmitter");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.setInputHandler=function(t,i){t.trigger=i.trigger.bind(i),i.subscribe&&i.unsubscribe&&(t.subscribe=i.subscribe.bind(i),t.unsubscribe=i.unsubscribe.bind(i))},s.setOutputHandler=function(t,i){i instanceof s&&i.bindThis(t),t.pipe=i.pipe.bind(i),t.unpipe=i.unpipe.bind(i),t.on=i.on.bind(i),t.addListener=t.on,t.removeListener=i.removeListener.bind(i)},s.prototype.emit=function(t,i){o.prototype.emit.apply(this,arguments);var e=0;for(e=0;e<this.downstream.length;e++)this.downstream[e].trigger&&this.downstream[e].trigger(t,i);for(e=0;e<this.downstreamFn.length;e++)this.downstreamFn[e](t,i);return this},s.prototype.trigger=s.prototype.emit,s.prototype.pipe=function(t){if(t.subscribe instanceof Function)return t.subscribe(this);var i=t instanceof Function?this.downstreamFn:this.downstream,e=i.indexOf(t);return 0>e&&i.push(t),t instanceof Function?t("pipe",null):t.trigger&&t.trigger("pipe",null),t},s.prototype.unpipe=function(t){if(t.unsubscribe instanceof Function)return t.unsubscribe(this);var i=t instanceof Function?this.downstreamFn:this.downstream,e=i.indexOf(t);return e>=0?(i.splice(e,1),t instanceof Function?t("unpipe",null):t.trigger&&t.trigger("unpipe",null),t):!1},s.prototype.on=function(t){if(o.prototype.on.apply(this,arguments),!(t in this.upstreamListeners)){var i=this.trigger.bind(this,t);this.upstreamListeners[t]=i;for(var e=0;e<this.upstream.length;e++)this.upstream[e].on(t,i)}return this},s.prototype.addListener=s.prototype.on,s.prototype.subscribe=function(t){var i=this.upstream.indexOf(t);if(0>i){this.upstream.push(t);for(var e in this.upstreamListeners)t.on(e,this.upstreamListeners[e])}return this},s.prototype.unsubscribe=function(t){var i=this.upstream.indexOf(t);if(i>=0){this.upstream.splice(i,1);for(var e in this.upstreamListeners)t.removeListener(e,this.upstreamListeners[e])}return this},e.exports=s}),define("famous/core/ElementAllocator",["require","exports","module"],function(t,i,e){function s(t){t||(t=document.createDocumentFragment()),this.container=t,this.detachedNodes={},this.nodeCount=0}s.prototype.migrate=function(t){var i=this.container;if(t!==i){if(i instanceof DocumentFragment)t.appendChild(i);else for(;i.hasChildNodes();)t.appendChild(i.removeChild(i.firstChild));this.container=t}},s.prototype.allocate=function(t){t=t.toLowerCase(),t in this.detachedNodes||(this.detachedNodes[t]=[]);var i,e=this.detachedNodes[t];return e.length>0?i=e.pop():(i=document.createElement(t),this.container.appendChild(i)),this.nodeCount++,i},s.prototype.deallocate=function(t){var i=t.nodeName.toLowerCase(),e=this.detachedNodes[i];e.push(t),this.nodeCount--},s.prototype.getNodeCount=function(){return this.nodeCount},e.exports=s}),define("famous/utilities/Utility",["require","exports","module"],function(t,i,e){var s={};s.Direction={X:0,Y:1,Z:2},s.after=function(t,i){var e=t;return function(){e--,0===e&&i.apply(this,arguments)}},s.loadURL=function(t,i){var e=new XMLHttpRequest;e.onreadystatechange=function(){4===this.readyState&&i&&i(this.responseText)},e.open("GET",t),e.send()},s.createDocumentFragmentFromHTML=function(t){var i=document.createElement("div");i.innerHTML=t;for(var e=document.createDocumentFragment();i.hasChildNodes();)e.appendChild(i.firstChild);return e},e.exports=s}),define("famous/transitions/MultipleTransition",["require","exports","module","famous/utilities/Utility"],function(t,i,e){function s(t){this.method=t,this._instances=[],this.state=[]}var o=t("famous/utilities/Utility");s.SUPPORTS_MULTIPLE=!0,s.prototype.get=function(){for(var t=0;t<this._instances.length;t++)this.state[t]=this._instances[t].get();return this.state},s.prototype.set=function(t,i,e){for(var s=o.after(t.length,e),n=0;n<t.length;n++)this._instances[n]||(this._instances[n]=new this.method),this._instances[n].set(t[n],i,s)},s.prototype.reset=function(t){for(var i=0;i<t.length;i++)this._instances[i]||(this._instances[i]=new this.method),this._instances[i].reset(t[i])},e.exports=s}),define("famous/transitions/TweenTransition",["require","exports","module"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._startTime=0,this._startValue=0,this._updateTime=0,this._endValue=0,this._curve=void 0,this._duration=0,this._active=!1,this._callback=void 0,this.state=0,this.velocity=void 0}function o(t,i,e){return(1-e)*t+e*i}function n(t){return t instanceof Object?t instanceof Array?t.slice(0):Object.create(t):t}function r(t,i){var e={curve:i.curve};return i.duration&&(e.duration=i.duration),i.speed&&(e.speed=i.speed),t instanceof Object&&(void 0!==t.duration&&(e.duration=t.duration),t.curve&&(e.curve=t.curve),t.speed&&(e.speed=t.speed)),"string"==typeof e.curve&&(e.curve=s.getCurve(e.curve)),e}function a(t,i,e,s,o){var n,r=1e-7,a=(e(o)-e(o-r))/r;if(t instanceof Array){n=[];for(var h=0;h<t.length;h++)n[h]="number"==typeof t[h]?a*(t[h]-i[h])/s:0}else n=a*(t-i)/s;return n}function h(t,i,e){var s;if(t instanceof Array){s=[];for(var n=0;n<t.length;n++)s[n]="number"==typeof t[n]?o(t[n],i[n],e):t[n]}else s=o(t,i,e);return s}s.Curves={linear:function(t){return t},easeIn:function(t){return t*t},easeOut:function(t){return t*(2-t)},easeInOut:function(t){return.5>=t?2*t*t:-2*t*t+4*t-1},easeOutBounce:function(t){return t*(3-2*t)},spring:function(t){return(1-t)*Math.sin(6*Math.PI*t)+t}},s.SUPPORTS_MULTIPLE=!0,s.DEFAULT_OPTIONS={curve:s.Curves.linear,duration:500,speed:0};var u={};s.registerCurve=function(t,i){return u[t]?!1:(u[t]=i,!0)},s.unregisterCurve=function(t){return u[t]?(delete u[t],!0):!1},s.getCurve=function(t){var i=u[t];if(void 0!==i)return i;throw Error("curve not registered")},s.getCurves=function(){return u},s.prototype.setOptions=function(t){void 0!==t.curve&&(this.options.curve=t.curve),void 0!==t.duration&&(this.options.duration=t.duration),void 0!==t.speed&&(this.options.speed=t.speed)},s.prototype.set=function(t,i,e){if(!i)return this.reset(t),void(e&&e());if(this._startValue=n(this.get()),i=r(i,this.options),i.speed){var s=this._startValue;if(s instanceof Object){var o=0;for(var a in s)o+=(t[a]-s[a])*(t[a]-s[a]);i.duration=Math.sqrt(o)/i.speed}else i.duration=Math.abs(t-s)/i.speed}this._startTime=Date.now(),this._endValue=n(t),this._startVelocity=n(i.velocity),this._duration=i.duration,this._curve=i.curve,this._active=!0,this._callback=e},s.prototype.reset=function(t,i){if(this._callback){var e=this._callback;this._callback=void 0,e()}this.state=n(t),this.velocity=n(i),this._startTime=0,this._duration=0,this._updateTime=0,this._startValue=this.state,this._startVelocity=this.velocity,this._endValue=this.state,this._active=!1},s.prototype.getVelocity=function(){return this.velocity},s.prototype.get=function(t){return this.update(t),this.state},s.prototype.update=function(t){if(this._active){if(t||(t=Date.now()),!(this._updateTime>=t)){this._updateTime=t;var i=t-this._startTime;if(i>=this._duration)this.state=this._endValue,this.velocity=a(this.state,this._startValue,this._curve,this._duration,1),this._active=!1;else if(0>i)this.state=this._startValue,this.velocity=this._startVelocity;else{var e=i/this._duration;this.state=h(this._startValue,this._endValue,this._curve(e)),this.velocity=a(this.state,this._startValue,this._curve,this._duration,e)}}}else if(this._callback){var s=this._callback;this._callback=void 0,s()}},s.prototype.isActive=function(){return this._active},s.prototype.halt=function(){this.reset(this.get())},s.registerCurve("linear",s.Curves.linear),s.registerCurve("easeIn",s.Curves.easeIn),s.registerCurve("easeOut",s.Curves.easeOut),s.registerCurve("easeInOut",s.Curves.easeInOut),s.registerCurve("easeOutBounce",s.Curves.easeOutBounce),s.registerCurve("spring",s.Curves.spring),s.customCurve=function(t,i){return t=t||0,i=i||0,function(e){return t*e+(-2*t-i+3)*e*e+(t+i-2)*e*e*e}},e.exports=s}),define("famous/transitions/Transitionable",["require","exports","module","./MultipleTransition","./TweenTransition"],function(t,i,e){function s(t){this.currentAction=null,this.actionQueue=[],this.callbackQueue=[],this.state=0,this.velocity=void 0,this._callback=void 0,this._engineInstance=null,this._currentMethod=null,this.set(t)}function o(){if(this._callback){var t=this._callback;this._callback=void 0,t()}if(this.actionQueue.length<=0)return void this.set(this.get());this.currentAction=this.actionQueue.shift(),this._callback=this.callbackQueue.shift();var i=null,e=this.currentAction[0],s=this.currentAction[1];s instanceof Object&&s.method?(i=s.method,"string"==typeof i&&(i=a[i])):i=r,this._currentMethod!==i&&(this._engineInstance=!(e instanceof Object)||i.SUPPORTS_MULTIPLE===!0||e.length<=i.SUPPORTS_MULTIPLE?new i:new n(i),this._currentMethod=i),this._engineInstance.reset(this.state,this.velocity),void 0!==this.velocity&&(s.velocity=this.velocity),this._engineInstance.set(e,s,o.bind(this))}var n=t("./MultipleTransition"),r=t("./TweenTransition"),a={};s.registerMethod=function(t,i){return t in a?!1:(a[t]=i,!0)},s.unregisterMethod=function(t){return t in a?(delete a[t],!0):!1},s.prototype.set=function(t,i,e){if(!i)return this.reset(t),e&&e(),this;var s=[t,i];return this.actionQueue.push(s),this.callbackQueue.push(e),this.currentAction||o.call(this),this},s.prototype.reset=function(t,i){this._currentMethod=null,this._engineInstance=null,this._callback=void 0,this.state=t,this.velocity=i,this.currentAction=null,this.actionQueue=[],this.callbackQueue=[]},s.prototype.delay=function(t,i){this.set(this.get(),{duration:t,curve:function(){return 0}},i)},s.prototype.get=function(t){return this._engineInstance&&(this._engineInstance.getVelocity&&(this.velocity=this._engineInstance.getVelocity()),this.state=this._engineInstance.get(t)),this.state},s.prototype.isActive=function(){return!!this.currentAction},s.prototype.halt=function(){this.set(this.get())},e.exports=s}),define("famous/core/Context",["require","exports","module","./RenderNode","./EventHandler","./ElementAllocator","./Transform","famous/transitions/Transitionable"],function(t,i,e){function s(t){return[t.clientWidth,t.clientHeight]}function o(t){this.container=t,this._allocator=new a(t),this._node=new n,this._eventOutput=new r,this._size=s(this.container),this._perspectiveState=new u(0),this._perspective=void 0,this._nodeContext={allocator:this._allocator,transform:h.identity,opacity:1,origin:c,align:null,size:this._size},this._eventOutput.on("resize",function(){this.setSize(s(this.container))}.bind(this))}var n=t("./RenderNode"),r=t("./EventHandler"),a=t("./ElementAllocator"),h=t("./Transform"),u=t("famous/transitions/Transitionable"),c=[0,0];o.prototype.getAllocator=function(){return this._allocator},o.prototype.add=function(t){return this._node.add(t)},o.prototype.migrate=function(t){t!==this.container&&(this.container=t,this._allocator.migrate(t))},o.prototype.getSize=function(){return this._size},o.prototype.setSize=function(t){t||(t=s(this.container)),this._size[0]=t[0],this._size[1]=t[1]},o.prototype.update=function(t){t&&(t.transform&&(this._nodeContext.transform=t.transform),t.opacity&&(this._nodeContext.opacity=t.opacity),t.origin&&(this._nodeContext.origin=t.origin),t.align&&(this._nodeContext.align=t.align),t.size&&(this._nodeContext.size=t.size));var i=this._perspectiveState.get();i!==this._perspective&&(this.container.style.perspective=i?i.toFixed()+"px":"",this.container.style.webkitPerspective=i?i.toFixed():"",this._perspective=i),this._node.commit(this._nodeContext)},o.prototype.getPerspective=function(){return this._perspectiveState.get()},o.prototype.setPerspective=function(t,i,e){return this._perspectiveState.set(t,i,e)},o.prototype.emit=function(t,i){return this._eventOutput.emit(t,i)},o.prototype.on=function(t,i){return this._eventOutput.on(t,i)},o.prototype.removeListener=function(t,i){return this._eventOutput.removeListener(t,i)},o.prototype.pipe=function(t){return this._eventOutput.pipe(t)},o.prototype.unpipe=function(t){return this._eventOutput.unpipe(t)},e.exports=o}),define("famous/core/OptionsManager",["require","exports","module","./EventHandler"],function(t,i,e){function s(t){this._value=t,this.eventOutput=null}function o(){this.eventOutput=new n,this.eventOutput.bindThis(this),n.setOutputHandler(this,this.eventOutput)}var n=t("./EventHandler");s.patch=function(t){for(var i=new s(t),e=1;e<arguments.length;e++)i.patch(arguments[e]);return t},s.prototype.patch=function(){for(var t=this._value,i=0;i<arguments.length;i++){var e=arguments[i];for(var s in e)s in t&&e[s]&&e[s].constructor===Object&&t[s]&&t[s].constructor===Object?(t.hasOwnProperty(s)||(t[s]=Object.create(t[s])),this.key(s).patch(e[s]),this.eventOutput&&this.eventOutput.emit("change",{id:s,value:this.key(s).value()})):this.set(s,e[s])}return this},s.prototype.setOptions=s.prototype.patch,s.prototype.key=function(t){var i=new s(this._value[t]);return(!(i._value instanceof Object)||i._value instanceof Array)&&(i._value={}),i},s.prototype.get=function(t){return this._value[t]},s.prototype.getOptions=s.prototype.get,s.prototype.set=function(t,i){var e=this.get(t);return this._value[t]=i,this.eventOutput&&i!==e&&this.eventOutput.emit("change",{id:t,value:i}),this},s.prototype.value=function(){return this._value},s.prototype.on=function(){return o.call(this),this.on.apply(this,arguments)},s.prototype.removeListener=function(){return o.call(this),this.removeListener.apply(this,arguments)},s.prototype.pipe=function(){return o.call(this),this.pipe.apply(this,arguments)},s.prototype.unpipe=function(){return o.call(this),this.unpipe.apply(this,arguments)},e.exports=s}),define("famous/core/Engine",["require","exports","module","./Context","./EventHandler","./OptionsManager"],function(t,i,e){function s(){g.runLoop?(c.step(),requestAnimationFrame(s)):m=!1}function o(){for(var t=0;t<p.length;t++)p[t].emit("resize");_.emit("resize")}var n,r,a=t("./Context"),h=t("./EventHandler"),u=t("./OptionsManager"),c={},p=[],l=[],f=[],d=Date.now(),m=!0,y={},_=new h,g={containerType:"div",containerClass:"famous-container",fpsCap:void 0,runLoop:!0},v=new u(g),O=10;c.step=function(){var t=Date.now();if(!(r&&r>t-d)){var i=0;for(n=t-d,d=t,_.emit("prerender"),i=0;i<l.length;i++)l[i].call(this);for(l.splice(0);f.length&&Date.now()-t<O;)f.shift().call(this);for(i=0;i<p.length;i++)p[i].update();_.emit("postrender")}},requestAnimationFrame(s),window.addEventListener("resize",o,!1),o(),window.addEventListener("touchmove",function(t){t.preventDefault()},!0),c.pipe=function(t){return t.subscribe instanceof Function?t.subscribe(c):_.pipe(t)},c.unpipe=function(t){return t.unsubscribe instanceof Function?t.unsubscribe(c):_.unpipe(t)},c.on=function(t,i){return t in y||(y[t]=_.emit.bind(_,t),document.body?document.body.addEventListener(t,y[t]):c.nextTick(function(t,i){document.body.addEventListener(t,i)}.bind(this,t,y[t]))),_.on(t,i)},c.emit=function(t,i){return _.emit(t,i)},c.removeListener=function(t,i){return _.removeListener(t,i)},c.getFPS=function(){return 1e3/n},c.setFPSCap=function(t){r=Math.floor(1e3/t)},c.getOptions=function(){return v.getOptions.apply(v,arguments)},c.setOptions=function(){return v.setOptions.apply(v,arguments)},c.createContext=function(t){var i=!1;t||(t=document.createElement(g.containerType),t.classList.add(g.containerClass),i=!0);var e=new a(t);return c.registerContext(e),i&&c.nextTick(function(t,i){document.body.appendChild(i),t.emit("resize")}.bind(this,e,t)),e},c.registerContext=function(t){return p.push(t),t},c.nextTick=function(t){l.push(t)},c.defer=function(t){f.push(t)},v.on("change",function(t){"fpsCap"===t.id?c.setFPSCap(t.value):"runLoop"===t.id&&!m&&t.value&&(m=!0,requestAnimationFrame(s))}),e.exports=c}),define("famous/core/Surface",["require","exports","module","./Entity","./EventHandler","./Transform"],function(t,i,e){function s(t){this.options={},this.properties={},this.content="",this.classList=[],this.size=null,this._classesDirty=!0,this._stylesDirty=!0,this._sizeDirty=!0,this._contentDirty=!0,this._dirtyClasses=[],this._matrix=null,this._opacity=1,this._origin=null,this._size=null,this.eventForwarder=function(t){this.emit(t.type,t)}.bind(this),this.eventHandler=new f,this.eventHandler.bindThis(this),this.id=l.register(this),t&&this.setOptions(t),this._currTarget=null}function o(t){for(var i in this.eventHandler.listeners)t.addEventListener(i,this.eventForwarder)}function n(t){for(var i in this.eventHandler.listeners)t.removeEventListener(i,this.eventForwarder)}function r(t){for(var i=0;i<this._dirtyClasses.length;i++)t.classList.remove(this._dirtyClasses[i]);this._dirtyClasses=[]}function a(t){for(var i in this.properties)t.style[i]=this.properties[i]}function h(t){for(var i in this.properties)t.style[i]=""}function u(t){t[12]=Math.round(t[12]*m)/m,t[13]=Math.round(t[13]*m)/m;for(var i="matrix3d(",e=0;15>e;e++)i+=t[e]<1e-6&&t[e]>-1e-6?"0,":t[e]+",";return i+=t[15]+")"}function c(t){return 100*t[0]+"% "+100*t[1]+"%"}function p(t,i){return t&&i?t[0]!==i[0]||t[1]!==i[1]:t!==i}var l=t("./Entity"),f=t("./EventHandler"),d=t("./Transform"),m=window.devicePixelRatio||1,y=void 0!==document.createElement("div").style.webkitTransform;s.prototype.elementType="div",s.prototype.elementClass="famous-surface",s.prototype.on=function(t,i){this._currTarget&&this._currTarget.addEventListener(t,this.eventForwarder),this.eventHandler.on(t,i)},s.prototype.removeListener=function(t,i){this.eventHandler.removeListener(t,i)},s.prototype.emit=function(t,i){i&&!i.origin&&(i.origin=this);var e=this.eventHandler.emit(t,i);return e&&i&&i.stopPropagation&&i.stopPropagation(),e},s.prototype.pipe=function(t){return this.eventHandler.pipe(t)},s.prototype.unpipe=function(t){return this.eventHandler.unpipe(t)},s.prototype.render=function(){return this.id},s.prototype.setProperties=function(t){for(var i in t)this.properties[i]=t[i];this._stylesDirty=!0},s.prototype.getProperties=function(){return this.properties},s.prototype.addClass=function(t){this.classList.indexOf(t)<0&&(this.classList.push(t),this._classesDirty=!0)},s.prototype.removeClass=function(t){var i=this.classList.indexOf(t);i>=0&&(this._dirtyClasses.push(this.classList.splice(i,1)[0]),this._classesDirty=!0)},s.prototype.setClasses=function(t){var i=0,e=[];for(i=0;i<this.classList.length;i++)t.indexOf(this.classList[i])<0&&e.push(this.classList[i]);for(i=0;i<e.length;i++)this.removeClass(e[i]);for(i=0;i<t.length;i++)this.addClass(t[i])},s.prototype.getClassList=function(){return this.classList},s.prototype.setContent=function(t){this.content!==t&&(this.content=t,this._contentDirty=!0)},s.prototype.getContent=function(){return this.content},s.prototype.setOptions=function(t){t.size&&this.setSize(t.size),t.classes&&this.setClasses(t.classes),t.properties&&this.setProperties(t.properties),t.content&&this.setContent(t.content)};var _;_=navigator.userAgent.toLowerCase().indexOf("firefox")>-1?function(t,i){t.style.zIndex=1e6*i[14]|0,t.style.transform=u(i)}:y?function(t,i){t.style.webkitTransform=u(i)}:function(t,i){t.style.transform=u(i)};var g=y?function(t,i){t.style.webkitTransformOrigin=c(i)}:function(t,i){t.style.transformOrigin=c(i)},v=y?function(t){t.style.webkitTransform="scale3d(0.0001,0.0001,1)",t.style.opacity=0}:function(t){t.style.transform="scale3d(0.0001,0.0001,1)",t.style.opacity=0};s.prototype.setup=function(t){var i=t.allocate(this.elementType);if(this.elementClass)if(this.elementClass instanceof Array)for(var e=0;e<this.elementClass.length;e++)i.classList.add(this.elementClass[e]);else i.classList.add(this.elementClass);i.style.display="",o.call(this,i),this._currTarget=i,this._stylesDirty=!0,this._classesDirty=!0,this._sizeDirty=!0,this._contentDirty=!0,this._matrix=null,this._opacity=void 0,this._origin=null,this._size=null},s.prototype.commit=function(t){this._currTarget||this.setup(t.allocator);var i=this._currTarget,e=t.transform,s=t.opacity,o=t.origin,n=t.size;if(this._classesDirty){r.call(this,i);for(var h=this.getClassList(),u=0;u<h.length;u++)i.classList.add(h[u]);this._classesDirty=!1}if(this._stylesDirty&&(a.call(this,i),this._stylesDirty=!1),this._contentDirty&&(this.deploy(i),this.eventHandler.emit("deploy"),this._contentDirty=!1),this.size){var c=n;n=[this.size[0],this.size[1]],void 0===n[0]&&c[0]&&(n[0]=c[0]),void 0===n[1]&&c[1]&&(n[1]=c[1])}if(n[0]===!0&&(n[0]=i.clientWidth),n[1]===!0&&(n[1]=i.clientHeight),p(this._size,n)&&(this._size||(this._size=[0,0]),this._size[0]=n[0],this._size[1]=n[1],this._sizeDirty=!0),!e&&this._matrix)return this._matrix=null,this._opacity=0,void v(i);if(this._opacity!==s&&(this._opacity=s,i.style.opacity=s>=1?"0.999999":s),p(this._origin,o)||d.notEquals(this._matrix,e)||this._sizeDirty){e||(e=d.identity),this._matrix=e;var l=e;o&&(this._origin||(this._origin=[0,0]),this._origin[0]=o[0],this._origin[1]=o[1],l=d.thenMove(e,[-this._size[0]*o[0],-this._size[1]*o[1],0]),g(i,o)),_(i,l)}this._sizeDirty&&(this._size&&(i.style.width=this.size&&this.size[0]===!0?"":this._size[0]+"px",i.style.height=this.size&&this.size[1]===!0?"":this._size[1]+"px"),this._sizeDirty=!1)},s.prototype.cleanup=function(t){var i=0,e=this._currTarget;
|
|
this.eventHandler.emit("recall"),this.recall(e),e.style.display="none",e.style.width="",e.style.height="",this._size=null,h.call(this,e);var s=this.getClassList();for(r.call(this,e),i=0;i<s.length;i++)e.classList.remove(s[i]);if(this.elementClass)if(this.elementClass instanceof Array)for(i=0;i<this.elementClass.length;i++)e.classList.remove(this.elementClass[i]);else e.classList.remove(this.elementClass);n.call(this,e),this._currTarget=null,t.deallocate(e),v(e)},s.prototype.deploy=function(t){var i=this.getContent();if(i instanceof Node){for(;t.hasChildNodes();)t.removeChild(t.firstChild);t.appendChild(i)}else t.innerHTML=i},s.prototype.recall=function(t){for(var i=document.createDocumentFragment();t.hasChildNodes();)i.appendChild(t.firstChild);this.setContent(i)},s.prototype.getSize=function(t){return t?this._size:this.size||this._size},s.prototype.setSize=function(t){this.size=t?[t[0],t[1]]:null,this._sizeDirty=!0},e.exports=s}),define("famous/core/Group",["require","exports","module","./Context","./Transform","./Surface"],function(t,i,e){function s(t){r.call(this,t),this._shouldRecalculateSize=!1,this._container=document.createDocumentFragment(),this.context=new o(this._container),this.setContent(this._container),this._groupSize=[void 0,void 0]}var o=t("./Context"),n=t("./Transform"),r=t("./Surface");s.SIZE_ZERO=[0,0],s.prototype=Object.create(r.prototype),s.prototype.elementType="div",s.prototype.elementClass="famous-group",s.prototype.add=function(){return this.context.add.apply(this.context,arguments)},s.prototype.render=function(){return r.prototype.render.call(this)},s.prototype.deploy=function(t){this.context.migrate(t)},s.prototype.recall=function(){this._container=document.createDocumentFragment(),this.context.migrate(this._container)},s.prototype.commit=function(t){var i=t.transform,e=t.origin,o=t.opacity,a=t.size,h=r.prototype.commit.call(this,{allocator:t.allocator,transform:n.thenMove(i,[-e[0]*a[0],-e[1]*a[1],0]),opacity:o,origin:e,size:s.SIZE_ZERO});return(a[0]!==this._groupSize[0]||a[1]!==this._groupSize[1])&&(this._groupSize[0]=a[0],this._groupSize[1]=a[1],this.context.setSize(a)),this.context.update({transform:n.translate(-e[0]*a[0],-e[1]*a[1],0),origin:e,size:a}),h},e.exports=s}),define("famous/transitions/TransitionableTransform",["require","exports","module","./Transitionable","famous/core/Transform","famous/utilities/Utility"],function(t,i,e){function s(t){this._final=r.identity.slice(),this.translate=new n([0,0,0]),this.rotate=new n([0,0,0]),this.skew=new n([0,0,0]),this.scale=new n([1,1,1]),t&&this.set(t)}function o(){return r.build({translate:this.translate.get(),rotate:this.rotate.get(),skew:this.skew.get(),scale:this.scale.get()})}var n=t("./Transitionable"),r=t("famous/core/Transform"),a=t("famous/utilities/Utility");s.prototype.setTranslate=function(t,i,e){return this.translate.set(t,i,e),this._final=this._final.slice(),this._final[12]=t[0],this._final[13]=t[1],void 0!==t[2]&&(this._final[14]=t[2]),this},s.prototype.setScale=function(t,i,e){return this.scale.set(t,i,e),this._final=this._final.slice(),this._final[0]=t[0],this._final[5]=t[1],void 0!==t[2]&&(this._final[10]=t[2]),this},s.prototype.setRotate=function(t,i,e){return this.rotate.set(t,i,e),this._final=o.call(this),this._final=r.build({translate:this.translate.get(),rotate:t,scale:this.scale.get(),skew:this.skew.get()}),this},s.prototype.setSkew=function(t,i,e){return this.skew.set(t,i,e),this._final=r.build({translate:this.translate.get(),rotate:this.rotate.get(),scale:this.scale.get(),skew:t}),this},s.prototype.set=function(t,i,e){this._final=t;var s=r.interpret(t),o=e?a.after(4,e):null;return this.translate.set(s.translate,i,o),this.rotate.set(s.rotate,i,o),this.skew.set(s.skew,i,o),this.scale.set(s.scale,i,o),this},s.prototype.setDefaultTransition=function(t){this.translate.setDefault(t),this.rotate.setDefault(t),this.skew.setDefault(t),this.scale.setDefault(t)},s.prototype.get=function(){return this.isActive()?o.call(this):this._final},s.prototype.getFinal=function(){return this._final},s.prototype.isActive=function(){return this.translate.isActive()||this.rotate.isActive()||this.scale.isActive()||this.skew.isActive()},s.prototype.halt=function(){this._final=this.get(),this.translate.halt(),this.rotate.halt(),this.skew.halt(),this.scale.halt()},e.exports=s}),define("famous/core/Modifier",["require","exports","module","./Transform","famous/transitions/Transitionable","famous/transitions/TransitionableTransform"],function(t,i,e){function s(t){this._transformGetter=null,this._opacityGetter=null,this._originGetter=null,this._alignGetter=null,this._sizeGetter=null,this._legacyStates={},this._output={transform:n.identity,opacity:1,origin:null,align:null,size:null,target:null},t&&(t.transform&&this.transformFrom(t.transform),void 0!==t.opacity&&this.opacityFrom(t.opacity),t.origin&&this.originFrom(t.origin),t.align&&this.alignFrom(t.align),t.size&&this.sizeFrom(t.size))}function o(){this._transformGetter&&(this._output.transform=this._transformGetter()),this._opacityGetter&&(this._output.opacity=this._opacityGetter()),this._originGetter&&(this._output.origin=this._originGetter()),this._alignGetter&&(this._output.align=this._alignGetter()),this._sizeGetter&&(this._output.size=this._sizeGetter())}var n=t("./Transform"),r=t("famous/transitions/Transitionable"),a=t("famous/transitions/TransitionableTransform");s.prototype.transformFrom=function(t){return t instanceof Function?this._transformGetter=t:t instanceof Object&&t.get?this._transformGetter=t.get.bind(t):(this._transformGetter=null,this._output.transform=t),this},s.prototype.opacityFrom=function(t){return t instanceof Function?this._opacityGetter=t:t instanceof Object&&t.get?this._opacityGetter=t.get.bind(t):(this._opacityGetter=null,this._output.opacity=t),this},s.prototype.originFrom=function(t){return t instanceof Function?this._originGetter=t:t instanceof Object&&t.get?this._originGetter=t.get.bind(t):(this._originGetter=null,this._output.origin=t),this},s.prototype.alignFrom=function(t){return t instanceof Function?this._alignGetter=t:t instanceof Object&&t.get?this._alignGetter=t.get.bind(t):(this._alignGetter=null,this._output.align=t),this},s.prototype.sizeFrom=function(t){return t instanceof Function?this._sizeGetter=t:t instanceof Object&&t.get?this._sizeGetter=t.get.bind(t):(this._sizeGetter=null,this._output.size=t),this},s.prototype.setTransform=function(t,i,e){return i||this._legacyStates.transform?(this._legacyStates.transform||(this._legacyStates.transform=new a(this._output.transform)),this._transformGetter||this.transformFrom(this._legacyStates.transform),this._legacyStates.transform.set(t,i,e),this):this.transformFrom(t)},s.prototype.setOpacity=function(t,i,e){return i||this._legacyStates.opacity?(this._legacyStates.opacity||(this._legacyStates.opacity=new r(this._output.opacity)),this._opacityGetter||this.opacityFrom(this._legacyStates.opacity),this._legacyStates.opacity.set(t,i,e)):this.opacityFrom(t)},s.prototype.setOrigin=function(t,i,e){return i||this._legacyStates.origin?(this._legacyStates.origin||(this._legacyStates.origin=new r(this._output.origin||[0,0])),this._originGetter||this.originFrom(this._legacyStates.origin),this._legacyStates.origin.set(t,i,e),this):this.originFrom(t)},s.prototype.setAlign=function(t,i,e){return i||this._legacyStates.align?(this._legacyStates.align||(this._legacyStates.align=new r(this._output.align||[0,0])),this._alignGetter||this.alignFrom(this._legacyStates.align),this._legacyStates.align.set(t,i,e),this):this.alignFrom(t)},s.prototype.setSize=function(t,i,e){return t&&(i||this._legacyStates.size)?(this._legacyStates.size||(this._legacyStates.size=new r(this._output.size||[0,0])),this._sizeGetter||this.sizeFrom(this._legacyStates.size),this._legacyStates.size.set(t,i,e),this):this.sizeFrom(t)},s.prototype.halt=function(){this._legacyStates.transform&&this._legacyStates.transform.halt(),this._legacyStates.opacity&&this._legacyStates.opacity.halt(),this._legacyStates.origin&&this._legacyStates.origin.halt(),this._legacyStates.align&&this._legacyStates.align.halt(),this._legacyStates.size&&this._legacyStates.size.halt(),this._transformGetter=null,this._opacityGetter=null,this._originGetter=null,this._alignGetter=null,this._sizeGetter=null},s.prototype.getTransform=function(){return this._transformGetter()},s.prototype.getFinalTransform=function(){return this._legacyStates.transform?this._legacyStates.transform.getFinal():this._output.transform},s.prototype.getOpacity=function(){return this._opacityGetter()},s.prototype.getOrigin=function(){return this._originGetter()},s.prototype.getAlign=function(){return this._alignGetter()},s.prototype.getSize=function(){return this._sizeGetter?this._sizeGetter():this._output.size},s.prototype.modify=function(t){return o.call(this),this._output.target=t,this._output},e.exports=s}),define("famous/core/Scene",["require","exports","module","./Transform","./Modifier","./RenderNode"],function(t,i,e){function s(t){this.id=null,this._objects=null,this.node=new c,this._definition=null,t&&this.load(t)}function o(t){for(var i in p)if(i in t){var e=t[i];return e instanceof Array||(e=[e]),p[i].apply(this,e)}}function n(t){var i=t.transform,e=t.opacity,s=t.origin,n=t.size,r=h.identity;if(i instanceof Array)if(16===i.length&&"number"==typeof i[0])r=i;else for(var a=0;a<i.length;a++)r=h.multiply(r,o(i[a]));else i instanceof Object&&(r=o(i));var c=new u({transform:r,opacity:e,origin:s,size:n});return c}function r(t){for(var i=new c,e=0;e<t.length;e++){var s=a.call(this,t[e]);s&&i.add(s)}return i}function a(t){var i,e;if(t instanceof Array)i=r.call(this,t);else if(e=this._objects.length,t.render&&t.render instanceof Function)i=t;else if(t.target){var s=a.call(this,t.target),o=n.call(this,t);i=new c(o),i.add(s),t.id&&(this.id[t.id]=o)}else t.id&&(i=new c,this.id[t.id]=i);return this._objects[e]=i,i}var h=t("./Transform"),u=t("./Modifier"),c=t("./RenderNode"),p={translate:h.translate,rotate:h.rotate,rotateX:h.rotateX,rotateY:h.rotateY,rotateZ:h.rotateZ,rotateAxis:h.rotateAxis,scale:h.scale,skew:h.skew,matrix3d:function(){return arguments}};s.prototype.create=function(){return new s(this._definition)},s.prototype.load=function(t){this._definition=t,this.id={},this._objects=[],this.node.set(a.call(this,t))},s.prototype.add=function(){return this.node.add.apply(this.node,arguments)},s.prototype.render=function(){return this.node.render.apply(this.node,arguments)},e.exports=s}),define("famous/core/View",["require","exports","module","./EventHandler","./OptionsManager","./RenderNode"],function(t,i,e){function s(t){this._node=new r,this._eventInput=new o,this._eventOutput=new o,o.setInputHandler(this,this._eventInput),o.setOutputHandler(this,this._eventOutput),this.options=Object.create(this.constructor.DEFAULT_OPTIONS||s.DEFAULT_OPTIONS),this._optionsManager=new n(this.options),t&&this.setOptions(t)}var o=t("./EventHandler"),n=t("./OptionsManager"),r=t("./RenderNode");s.DEFAULT_OPTIONS={},s.prototype.getOptions=function(){return this._optionsManager.value()},s.prototype.setOptions=function(t){this._optionsManager.patch(t)},s.prototype.add=function(){return this._node.add.apply(this._node,arguments)},s.prototype._add=s.prototype.add,s.prototype.render=function(){return this._node.render()},s.prototype.getSize=function(){return this._node&&this._node.getSize?this._node.getSize.apply(this._node,arguments)||this.options.size:this.options.size},e.exports=s}),define("famous/core/ViewSequence",["require","exports","module"],function(t,i,e){function s(t){t||(t=[]),t instanceof Array&&(t={array:t}),this._=null,this.index=t.index||0,t.array?this._=new this.constructor.Backing(t.array):t._&&(this._=t._),this.index===this._.firstIndex&&(this._.firstNode=this),this.index===this._.firstIndex+this._.array.length-1&&(this._.lastNode=this),void 0!==t.loop&&(this._.loop=t.loop),this._previousNode=null,this._nextNode=null}s.Backing=function(t){this.array=t,this.firstIndex=0,this.loop=!1,this.firstNode=null,this.lastNode=null},s.Backing.prototype.getValue=function(t){var i=t-this.firstIndex;return 0>i||i>=this.array.length?null:this.array[i]},s.Backing.prototype.setValue=function(t,i){this.array[t-this.firstIndex]=i},s.Backing.prototype.reindex=function(t,i,e){if(this.array[0]){for(var s=0,o=this.firstIndex,n=e-i,r=this.firstNode;t-1>o;)r=r.getNext(),o++;var a=r;for(s=0;i>s;s++)r=r.getNext(),r&&(r._previousNode=a);var h=r?r.getNext():null;for(a._nextNode=null,r=a,s=0;e>s;s++)r=r.getNext();if(o+=e,r!==h&&(r._nextNode=h,h&&(h._previousNode=r)),h)for(r=h,o++;r&&o<this.array.length+this.firstIndex;)r._nextNode?r.index+=n:r.index=o,r=r.getNext(),o++}},s.prototype.getPrevious=function(){return this.index===this._.firstIndex?this._.loop?(this._previousNode=this._.lastNode||new this.constructor({_:this._,index:this._.firstIndex+this._.array.length-1}),this._previousNode._nextNode=this):this._previousNode=null:this._previousNode||(this._previousNode=new this.constructor({_:this._,index:this.index-1}),this._previousNode._nextNode=this),this._previousNode},s.prototype.getNext=function(){return this.index===this._.firstIndex+this._.array.length-1?this._.loop?(this._nextNode=this._.firstNode||new this.constructor({_:this._,index:this._.firstIndex}),this._nextNode._previousNode=this):this._nextNode=null:this._nextNode||(this._nextNode=new this.constructor({_:this._,index:this.index+1}),this._nextNode._previousNode=this),this._nextNode},s.prototype.getIndex=function(){return this.index},s.prototype.toString=function(){return""+this.index},s.prototype.unshift=function(){this._.array.unshift.apply(this._.array,arguments),this._.firstIndex-=arguments.length},s.prototype.push=function(){this._.array.push.apply(this._.array,arguments)},s.prototype.splice=function(t,i){var e=Array.prototype.slice.call(arguments,2);this._.array.splice.apply(this._.array,[t-this._.firstIndex,i].concat(e)),this._.reindex(t,i,e.length)},s.prototype.swap=function(t){var i=t.get(),e=this.get();this._.setValue(this.index,i),this._.setValue(t.index,e);var s=this._previousNode,o=this._nextNode,n=this.index,r=t._previousNode,a=t._nextNode,h=t.index;this.index=h,this._previousNode=r===this?t:r,this._previousNode&&(this._previousNode._nextNode=this),this._nextNode=a===this?t:a,this._nextNode&&(this._nextNode._previousNode=this),t.index=n,t._previousNode=s===t?this:s,t._previousNode&&(t._previousNode._nextNode=t),t._nextNode=o===t?this:o,t._nextNode&&(t._nextNode._previousNode=t),this.index===this._.firstIndex?this._.firstNode=this:this.index===this._.firstIndex+this._.array.length-1&&(this._.lastNode=this),t.index===this._.firstIndex?this._.firstNode=t:t.index===this._.firstIndex+this._.array.length-1&&(this._.lastNode=t)},s.prototype.get=function(){return this._.getValue(this.index)},s.prototype.getSize=function(){var t=this.get();return t?t.getSize():null},s.prototype.render=function(){var t=this.get();return t?t.render.apply(t,arguments):null},e.exports=s}),define("famous/math/Vector",["require","exports","module"],function(t,i,e){function s(t,i,e){return 1===arguments.length?this.set(t):(this.x=t||0,this.y=i||0,this.z=e||0),this}function o(t,i,e){return this.x=t,this.y=i,this.z=e,this}function n(t){return o.call(this,t[0],t[1],t[2]||0)}function r(t){return o.call(this,t.x,t.y,t.z)}function a(t){return o.call(this,t,0,0)}var h=new s(0,0,0);s.prototype.add=function(t){return o.call(h,this.x+t.x,this.y+t.y,this.z+t.z)},s.prototype.sub=function(t){return o.call(h,this.x-t.x,this.y-t.y,this.z-t.z)},s.prototype.mult=function(t){return o.call(h,t*this.x,t*this.y,t*this.z)},s.prototype.div=function(t){return this.mult(1/t)},s.prototype.cross=function(t){var i=this.x,e=this.y,s=this.z,n=t.x,r=t.y,a=t.z;return o.call(h,s*r-e*a,i*a-s*n,e*n-i*r)},s.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},s.prototype.rotateX=function(t){var i=this.x,e=this.y,s=this.z,n=Math.cos(t),r=Math.sin(t);return o.call(h,i,e*n-s*r,e*r+s*n)},s.prototype.rotateY=function(t){var i=this.x,e=this.y,s=this.z,n=Math.cos(t),r=Math.sin(t);return o.call(h,s*r+i*n,e,s*n-i*r)},s.prototype.rotateZ=function(t){var i=this.x,e=this.y,s=this.z,n=Math.cos(t),r=Math.sin(t);return o.call(h,i*n-e*r,i*r+e*n,s)},s.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},s.prototype.normSquared=function(){return this.dot(this)},s.prototype.norm=function(){return Math.sqrt(this.normSquared())},s.prototype.normalize=function(t){0===arguments.length&&(t=1);var i=this.norm();return i>1e-7?r.call(h,this.mult(t/i)):o.call(h,t,0,0)},s.prototype.clone=function(){return new s(this)},s.prototype.isZero=function(){return!(this.x||this.y||this.z)},s.prototype.set=function(t){return t instanceof Array?n.call(this,t):t instanceof s?r.call(this,t):"number"==typeof t?a.call(this,t):void 0},s.prototype.setXYZ=function(){return o.apply(this,arguments)},s.prototype.set1D=function(t){return a.call(this,t)},s.prototype.put=function(t){r.call(t,h)},s.prototype.clear=function(){return o.call(this,0,0,0)},s.prototype.cap=function u(u){if(1/0===u)return r.call(h,this);var t=this.norm();return t>u?r.call(h,this.mult(u/t)):r.call(h,this)},s.prototype.project=function(t){return t.mult(this.dot(t))},s.prototype.reflectAcross=function(t){return t.normalize().put(t),r(h,this.sub(this.project(t).mult(2)))},s.prototype.get=function(){return[this.x,this.y,this.z]},s.prototype.get1D=function(){return this.x},e.exports=s}),define("famous/math/Matrix",["require","exports","module","./Vector"],function(t,i,e){function s(t){return this.values=t||[[1,0,0],[0,1,0],[0,0,1]],this}var o=t("./Vector"),n=new s,r=new o;s.prototype.get=function(){return this.values},s.prototype.set=function(t){this.values=t},s.prototype.vectorMultiply=function(t){var i=this.get(),e=t.x,s=t.y,o=t.z,n=i[0],a=i[1],h=i[2],u=n[0],c=n[1],p=n[2],l=a[0],f=a[1],d=a[2],m=h[0],y=h[1],_=h[2];return r.setXYZ(u*e+c*s+p*o,l*e+f*s+d*o,m*e+y*s+_*o)},s.prototype.multiply=function(t){for(var i=this.get(),e=[[]],s=0;3>s;s++){e[s]=[];for(var o=0;3>o;o++){for(var r=0,a=0;3>a;a++)r+=i[s][a]*t[a][o];e[s][o]=r}}return n.set(e)},s.prototype.transpose=function(){for(var t=[],i=this.get(),e=0;3>e;e++)for(var s=0;3>s;s++)t[e][s]=i[s][e];return n.set(t)},s.prototype.clone=function(){for(var t=this.get(),i=[],e=0;3>e;e++)i[e]=t[e].slice();return new s(i)},e.exports=s}),define("famous/math/Quaternion",["require","exports","module","./Matrix"],function(t,i,e){function s(t,i,e,s){return 1===arguments.length?this.set(t):(this.w=void 0!==t?t:1,this.x=void 0!==i?i:0,this.y=void 0!==e?e:0,this.z=void 0!==s?s:0),this}var o=t("./Matrix"),n=new s(1,0,0,0);s.prototype.add=function(t){return n.setWXYZ(this.w+t.w,this.x+t.x,this.y+t.y,this.z+t.z)},s.prototype.sub=function(t){return n.setWXYZ(this.w-t.w,this.x-t.x,this.y-t.y,this.z-t.z)},s.prototype.scalarDivide=function(t){return this.scalarMultiply(1/t)},s.prototype.scalarMultiply=function(t){return n.setWXYZ(this.w*t,this.x*t,this.y*t,this.z*t)},s.prototype.multiply=function(t){var i=this.x,e=this.y,s=this.z,o=this.w,r=t.x,a=t.y,h=t.z,u=t.w||0;return n.setWXYZ(o*u-i*r-e*a-s*h,i*u+r*o+a*s-e*h,e*u+a*o+i*h-r*s,s*u+h*o+r*e-i*a)};var r=new s(1,0,0,0);s.prototype.rotateVector=function(t){return r.set(this.conj()),n.set(this.multiply(t).multiply(r))},s.prototype.inverse=function(){return n.set(this.conj().scalarDivide(this.normSquared()))},s.prototype.negate=function(){return this.scalarMultiply(-1)},s.prototype.conj=function(){return n.setWXYZ(this.w,-this.x,-this.y,-this.z)},s.prototype.normalize=function(t){return t=void 0===t?1:t,this.scalarDivide(t*this.norm())},s.prototype.makeFromAngleAndAxis=function(t,i){var e=i.normalize(),s=.5*t,o=-Math.sin(s);return this.x=o*e.x,this.y=o*e.y,this.z=o*e.z,this.w=Math.cos(s),this},s.prototype.setWXYZ=function(t,i,e,s){return n.clear(),this.w=t,this.x=i,this.y=e,this.z=s,this},s.prototype.set=function(t){return t instanceof Array?(this.w=t[0],this.x=t[1],this.y=t[2],this.z=t[3]):(this.w=t.w,this.x=t.x,this.y=t.y,this.z=t.z),this!==n&&n.clear(),this},s.prototype.put=function(t){t.set(n)},s.prototype.clone=function(){return new s(this)},s.prototype.clear=function(){return this.w=1,this.x=0,this.y=0,this.z=0,this},s.prototype.isEqual=function(t){return t.w===this.w&&t.x===this.x&&t.y===this.y&&t.z===this.z},s.prototype.dot=function(t){return this.w*t.w+this.x*t.x+this.y*t.y+this.z*t.z},s.prototype.normSquared=function(){return this.dot(this)},s.prototype.norm=function(){return Math.sqrt(this.normSquared())},s.prototype.isZero=function(){return!(this.x||this.y||this.z)},s.prototype.getTransform=function(){var t=this.normalize(1),i=t.x,e=t.y,s=t.z,o=t.w;return[1-2*e*e-2*s*s,2*i*e-2*s*o,2*i*s+2*e*o,0,2*i*e+2*s*o,1-2*i*i-2*s*s,2*e*s-2*i*o,0,2*i*s-2*e*o,2*e*s+2*i*o,1-2*i*i-2*e*e,0,0,0,0,1]};var a=new o;s.prototype.getMatrix=function(){var t=this.normalize(1),i=t.x,e=t.y,s=t.z,o=t.w;return a.set([[1-2*e*e-2*s*s,2*i*e+2*s*o,2*i*s-2*e*o],[2*i*e-2*s*o,1-2*i*i-2*s*s,2*e*s+2*i*o],[2*i*s+2*e*o,2*e*s-2*i*o,1-2*i*i-2*e*e]])};var h=1e-5;s.prototype.slerp=function(t,i){var e,s,o,r,a;return s=this.dot(t),1-s>h?(e=Math.acos(s),o=Math.sin(e),r=Math.sin((1-i)*e)/o,a=Math.sin(i*e)/o):(r=1-i,a=i),n.set(this.scalarMultiply(r/a).add(t).multiply(a))},e.exports=s}),define("famous/math/Random",["require","exports","module"],function(t,i,e){function s(t,i){return t+n()*(i-t)}function o(t,i){return t+n()*(i-t+1)>>0}var n=Math.random,r={};r.integer=function(t,i,e){if(t=void 0!==t?t:0,i=void 0!==i?i:1,void 0!==e){for(var s=[],n=0;e>n;n++)s.push(o(t,i));return s}return o(t,i)},r.range=function(t,i,e){if(t=void 0!==t?t:0,i=void 0!==i?i:1,void 0!==e){for(var o=[],n=0;e>n;n++)o.push(s(t,i));return o}return s(t,i)},r.sign=function(t){return t=void 0!==t?t:.5,n()<t?1:-1},r.bool=function(t){return t=void 0!==t?t:.5,n()<t},e.exports=r}),define("famous/math/Utilities",["require","exports","module"],function(t,i,e){var s={};s.clamp=function(t,i){return Math.max(Math.min(t,i[1]),i[0])},s.length=function(t){for(var i=0,e=0;e<t.length;e++)i+=t[e]*t[e];return Math.sqrt(i)},e.exports=s}),define("famous/inputs/Accumulator",["require","exports","module","famous/core/EventHandler","famous/transitions/Transitionable"],function(t,i,e){function s(t,i){void 0===i&&(i="update"),this._state=t&&t.get&&t.set?t:new r(t||0),this._eventInput=new n,n.setInputHandler(this,this._eventInput),this._eventInput.on(i,o.bind(this))}function o(t){var i=t.delta,e=this.get();if(i.constructor===e.constructor){var s=i instanceof Array?[e[0]+i[0],e[1]+i[1]]:e+i;this.set(s)}}var n=t("famous/core/EventHandler"),r=t("famous/transitions/Transitionable");s.prototype.get=function(){return this._state.get()},s.prototype.set=function(t){this._state.set(t)},e.exports=s}),define("famous/inputs/DesktopEmulationMode",["require","exports","module"],function(){function t(t){window.addEventListener(t,function(t){return t.stopPropagation(),!1},!0)}var i="ontouchstart"in window;i&&(t("mousedown"),t("mousemove"),t("mouseup"),t("mouseleave"))}),define("famous/inputs/FastClick",["require","exports","module"],function(){if(window.CustomEvent){var t=300,i=500,e={},s={},o=Date.now;window.addEventListener("touchstart",function(t){for(var i=o(),s=0;s<t.changedTouches.length;s++){var n=t.changedTouches[s];e[n.identifier]=i}}),window.addEventListener("touchmove",function(t){for(var i=0;i<t.changedTouches.length;i++){var s=t.changedTouches[i];delete e[s.identifier]}}),window.addEventListener("touchend",function(i){for(var n=o(),r=0;r<i.changedTouches.length;r++){var a=i.changedTouches[r],h=e[a.identifier];if(h&&t>n-h){var u=new window.CustomEvent("click",{bubbles:!0,details:a});s[n]=i,i.target.dispatchEvent(u)}delete e[a.identifier]}}),window.addEventListener("click",function(t){var e=o();for(var n in s){var r=s[n];i>e-n?t instanceof window.MouseEvent&&t.target===r.target&&t.stopPropagation():delete s[n]}},!0)}}),define("famous/inputs/GenericSync",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(t,i){this._eventInput=new n,this._eventOutput=new n,n.setInputHandler(this,this._eventInput),n.setOutputHandler(this,this._eventOutput),this._syncs={},t&&this.addSync(t),i&&this.setOptions(i)}function o(t,i){r[t]&&(this._syncs[t]=new r[t](i),this.pipeSync(t))}var n=t("famous/core/EventHandler");s.DIRECTION_X=0,s.DIRECTION_Y=1,s.DIRECTION_Z=2;var r={};s.register=function(t){for(var i in t){if(r[i]){if(r[i]===t[i])return;throw Error("this key is registered to a different sync class")}r[i]=t[i]}},s.prototype.setOptions=function(t){for(var i in this._syncs)this._syncs[i].setOptions(t)},s.prototype.pipeSync=function(t){var i=this._syncs[t];this._eventInput.pipe(i),i.pipe(this._eventOutput)},s.prototype.unpipeSync=function(t){var i=this._syncs[t];this._eventInput.unpipe(i),i.unpipe(this._eventOutput)},s.prototype.addSync=function(t){if(t instanceof Array)for(var i=0;i<t.length;i++)o.call(this,t[i]);else if(t instanceof Object)for(var e in t)o.call(this,e,t[e])},e.exports=s}),define("famous/inputs/MouseSync",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._eventInput=new h,this._eventOutput=new h,h.setInputHandler(this,this._eventInput),h.setOutputHandler(this,this._eventOutput),this._eventInput.on("mousedown",o.bind(this)),this._eventInput.on("mousemove",n.bind(this)),this._eventInput.on("mouseup",r.bind(this)),this.options.propogate?this._eventInput.on("mouseleave",a.bind(this)):this._eventInput.on("mouseleave",r.bind(this)),this._payload={delta:null,position:null,velocity:null,clientX:0,clientY:0,offsetX:0,offsetY:0},this._position=null,this._prevCoord=void 0,this._prevTime=void 0,this._down=!1,this._moved=!1}function o(t){var i,e;t.preventDefault();var s=t.clientX,o=t.clientY;this._prevCoord=[s,o],this._prevTime=c(),this._down=!0,this._move=!1,void 0!==this.options.direction?(this._position=0,i=0,e=0):(this._position=[0,0],i=[0,0],e=[0,0]);var n=this._payload;n.delta=i,n.position=this._position,n.velocity=e,n.clientX=s,n.clientY=o,n.offsetX=t.offsetX,n.offsetY=t.offsetY,this._eventOutput.emit("start",n)}function n(t){if(this._prevCoord){var i=this._prevCoord,e=this._prevTime,o=t.clientX,n=t.clientY,r=c(),a=o-i[0],h=n-i[1];this.options.rails&&(Math.abs(a)>Math.abs(h)?h=0:a=0);var p,l,f=Math.max(r-e,u),d=a/f,m=h/f,y=this.options.scale;this.options.direction===s.DIRECTION_X?(l=y*a,p=y*d,this._position+=l):this.options.direction===s.DIRECTION_Y?(l=y*h,p=y*m,this._position+=l):(l=[y*a,y*h],p=[y*d,y*m],this._position[0]+=l[0],this._position[1]+=l[1]);var _=this._payload;_.delta=l,_.position=this._position,_.velocity=p,_.clientX=o,_.clientY=n,_.offsetX=t.offsetX,_.offsetY=t.offsetY,this._eventOutput.emit("update",_),this._prevCoord=[o,n],this._prevTime=r,this._move=!0}}function r(){this._down&&(this._eventOutput.emit("end",this._payload),this._prevCoord=void 0,this._prevTime=void 0,this._down=!1,this._move=!1)}function a(t){if(this._down&&this._move){var i=n.bind(this),e=function(t){r.call(this,t),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",e)}.bind(this,t);document.addEventListener("mousemove",i),document.addEventListener("mouseup",e)}}var h=t("famous/core/EventHandler");s.DEFAULT_OPTIONS={direction:void 0,rails:!1,scale:1,propogate:!0},s.DIRECTION_X=0,s.DIRECTION_Y=1;var u=8,c=Date.now;s.prototype.getOptions=function(){return this.options},s.prototype.setOptions=function(t){void 0!==t.direction&&(this.options.direction=t.direction),void 0!==t.rails&&(this.options.rails=t.rails),void 0!==t.scale&&(this.options.scale=t.scale),void 0!==t.propogate&&(this.options.propogate=t.propogate)},e.exports=s}),define("famous/inputs/TwoFingerSync",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(){this._eventInput=new o,this._eventOutput=new o,o.setInputHandler(this,this._eventInput),o.setOutputHandler(this,this._eventOutput),this.touchAEnabled=!1,this.touchAId=0,this.posA=null,this.timestampA=0,this.touchBEnabled=!1,this.touchBId=0,this.posB=null,this.timestampB=0,this._eventInput.on("touchstart",this.handleStart.bind(this)),this._eventInput.on("touchmove",this.handleMove.bind(this)),this._eventInput.on("touchend",this.handleEnd.bind(this)),this._eventInput.on("touchcancel",this.handleEnd.bind(this))}var o=t("famous/core/EventHandler");s.calculateAngle=function(t,i){var e=i[0]-t[0],s=i[1]-t[1];return Math.atan2(s,e)},s.calculateDistance=function(t,i){var e=i[0]-t[0],s=i[1]-t[1];return Math.sqrt(e*e+s*s)},s.calculateCenter=function(t,i){return[(t[0]+i[0])/2,(t[1]+i[1])/2]};var n=Date.now;s.prototype.handleStart=function(t){for(var i=0;i<t.changedTouches.length;i++){var e=t.changedTouches[i];this.touchAEnabled?this.touchBEnabled||(this.touchBId=e.identifier,this.touchBEnabled=!0,this.posB=[e.pageX,e.pageY],this.timestampB=n(),this._startUpdate(t)):(this.touchAId=e.identifier,this.touchAEnabled=!0,this.posA=[e.pageX,e.pageY],this.timestampA=n())}},s.prototype.handleMove=function(t){if(this.touchAEnabled&&this.touchBEnabled){for(var i,e=this.timestampA,s=this.timestampB,o=0;o<t.changedTouches.length;o++){var r=t.changedTouches[o];r.identifier===this.touchAId?(this.posA=[r.pageX,r.pageY],this.timestampA=n(),i=this.timestampA-e):r.identifier===this.touchBId&&(this.posB=[r.pageX,r.pageY],this.timestampB=n(),i=this.timestampB-s)}i&&this._moveUpdate(i)}},s.prototype.handleEnd=function(t){for(var i=0;i<t.changedTouches.length;i++){var e=t.changedTouches[i];(e.identifier===this.touchAId||e.identifier===this.touchBId)&&(this.touchAEnabled&&this.touchBEnabled&&this._eventOutput.emit("end",{touches:[this.touchAId,this.touchBId],angle:this._angle}),this.touchAEnabled=!1,this.touchAId=0,this.touchBEnabled=!1,this.touchBId=0)}},e.exports=s}),define("famous/inputs/PinchSync",["require","exports","module","./TwoFingerSync"],function(t,i,e){function s(t){o.call(this),this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._displacement=0,this._previousDistance=0}var o=t("./TwoFingerSync");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={scale:1},s.prototype._startUpdate=function(t){this._previousDistance=o.calculateDistance(this.posA,this.posB),this._displacement=0,this._eventOutput.emit("start",{count:t.touches.length,touches:[this.touchAId,this.touchBId],distance:this._dist,center:o.calculateCenter(this.posA,this.posB)})},s.prototype._moveUpdate=function(t){var i=o.calculateDistance(this.posA,this.posB),e=o.calculateCenter(this.posA,this.posB),s=this.options.scale,n=s*(i-this._previousDistance),r=n/t;this._previousDistance=i,this._displacement+=n,this._eventOutput.emit("update",{delta:n,velocity:r,distance:i,displacement:this._displacement,center:e,touches:[this.touchAId,this.touchBId]})},s.prototype.getOptions=function(){return this.options},s.prototype.setOptions=function(t){void 0!==t.scale&&(this.options.scale=t.scale)},e.exports=s}),define("famous/inputs/RotateSync",["require","exports","module","./TwoFingerSync"],function(t,i,e){function s(t){o.call(this),this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._angle=0,this._previousAngle=0}var o=t("./TwoFingerSync");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={scale:1},s.prototype._startUpdate=function(t){this._angle=0,this._previousAngle=o.calculateAngle(this.posA,this.posB);var i=o.calculateCenter(this.posA,this.posB);this._eventOutput.emit("start",{count:t.touches.length,angle:this._angle,center:i,touches:[this.touchAId,this.touchBId]})},s.prototype._moveUpdate=function(t){var i=this.options.scale,e=o.calculateAngle(this.posA,this.posB),s=o.calculateCenter(this.posA,this.posB),n=i*(e-this._previousAngle),r=n/t;this._angle+=n,this._eventOutput.emit("update",{delta:n,velocity:r,angle:this._angle,center:s,touches:[this.touchAId,this.touchBId]}),this._previousAngle=e},s.prototype.getOptions=function(){return this.options},s.prototype.setOptions=function(t){void 0!==t.scale&&(this.options.scale=t.scale)
|
|
},e.exports=s}),define("famous/inputs/ScaleSync",["require","exports","module","./TwoFingerSync"],function(t,i,e){function s(t){n.call(this),this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._scaleFactor=1,this._startDist=0,this._eventInput.on("pipe",o.bind(this))}function o(){this.touchAId=void 0,this.touchBId=void 0}var n=t("./TwoFingerSync");s.prototype=Object.create(n.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={scale:1},s.prototype._startUpdate=function(t){this._scaleFactor=1,this._startDist=n.calculateDistance(this.posA,this.posB),this._eventOutput.emit("start",{count:t.touches.length,touches:[this.touchAId,this.touchBId],distance:this._startDist,center:n.calculateCenter(this.posA,this.posB)})},s.prototype._moveUpdate=function(t){var i=this.options.scale,e=n.calculateDistance(this.posA,this.posB),s=n.calculateCenter(this.posA,this.posB),o=(e-this._startDist)/this._startDist,r=Math.max(1+i*o,0),a=(r-this._scaleFactor)/t;this._eventOutput.emit("update",{delta:o,scale:r,velocity:a,distance:e,center:s,touches:[this.touchAId,this.touchBId]}),this._scaleFactor=r},s.prototype.getOptions=function(){return this.options},s.prototype.setOptions=function(t){void 0!==t.scale&&(this.options.scale=t.scale)},e.exports=s}),define("famous/inputs/ScrollSync",["require","exports","module","famous/core/EventHandler","famous/core/Engine"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._payload={delta:null,position:null,velocity:null,slip:!0},this._eventInput=new r,this._eventOutput=new r,r.setInputHandler(this,this._eventInput),r.setOutputHandler(this,this._eventOutput),this._position=void 0===this.options.direction?[0,0]:0,this._prevTime=void 0,this._prevVel=void 0,this._eventInput.on("mousewheel",n.bind(this)),this._eventInput.on("wheel",n.bind(this)),this._inProgress=!1,this._loopBound=!1}function o(){if(this._inProgress&&u()-this._prevTime>this.options.stallTime){this._position=void 0===this.options.direction?[0,0]:0,this._inProgress=!1;var t=Math.abs(this._prevVel)>=this.options.minimumEndSpeed?this._prevVel:0,i=this._payload;i.position=this._position,i.velocity=t,i.slip=!0,this._eventOutput.emit("end",i)}}function n(t){t.preventDefault(),this._inProgress||(this._inProgress=!0,y=this._payload,y.slip=!0,y.position=this._position,y.clientX=t.clientX,y.clientY=t.clientY,y.offsetX=t.offsetX,y.offsetY=t.offsetY,this._eventOutput.emit("start",y),this._loopBound||(a.on("prerender",o.bind(this)),this._loopBound=!0));var i=u(),e=this._prevTime||i,n=void 0!==t.wheelDeltaX?t.wheelDeltaX:-t.deltaX,r=void 0!==t.wheelDeltaY?t.wheelDeltaY:-t.deltaY;1===t.deltaMode&&(n*=this.options.lineHeight,r*=this.options.lineHeight),this.options.rails&&(Math.abs(n)>Math.abs(r)?r=0:n=0);var c,p,l=Math.max(i-e,h),f=n/l,d=r/l,m=this.options.scale;this.options.direction===s.DIRECTION_X?(p=m*n,c=m*f,this._position+=p):this.options.direction===s.DIRECTION_Y?(p=m*r,c=m*d,this._position+=p):(p=[m*n,m*r],c=[m*f,m*d],this._position[0]+=p[0],this._position[1]+=p[1]);var y=this._payload;y.delta=p,y.velocity=c,y.position=this._position,y.slip=!0,this._eventOutput.emit("update",y),this._prevTime=i,this._prevVel=c}var r=t("famous/core/EventHandler"),a=t("famous/core/Engine");s.DEFAULT_OPTIONS={direction:void 0,minimumEndSpeed:1/0,rails:!1,scale:1,stallTime:50,lineHeight:40},s.DIRECTION_X=0,s.DIRECTION_Y=1;var h=8,u=Date.now;s.prototype.getOptions=function(){return this.options},s.prototype.setOptions=function(t){void 0!==t.direction&&(this.options.direction=t.direction),void 0!==t.minimumEndSpeed&&(this.options.minimumEndSpeed=t.minimumEndSpeed),void 0!==t.rails&&(this.options.rails=t.rails),void 0!==t.scale&&(this.options.scale=t.scale),void 0!==t.stallTime&&(this.options.stallTime=t.stallTime)},e.exports=s}),define("famous/inputs/TouchTracker",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(t,i,e){return{x:t.clientX,y:t.clientY,identifier:t.identifier,origin:i.origin,timestamp:c(),count:i.touches.length,history:e}}function o(t){for(var i=0;i<t.changedTouches.length;i++){var e=t.changedTouches[i],o=s(e,t,null);this.eventOutput.emit("trackstart",o),this.selective||this.touchHistory[e.identifier]||this.track(o)}}function n(t){for(var i=0;i<t.changedTouches.length;i++){var e=t.changedTouches[i],o=this.touchHistory[e.identifier];if(o){var n=s(e,t,o);this.touchHistory[e.identifier].push(n),this.eventOutput.emit("trackmove",n)}}}function r(t){for(var i=0;i<t.changedTouches.length;i++){var e=t.changedTouches[i],o=this.touchHistory[e.identifier];if(o){var n=s(e,t,o);this.eventOutput.emit("trackend",n),delete this.touchHistory[e.identifier]}}}function a(){for(var t in this.touchHistory){var i=this.touchHistory[t];this.eventOutput.emit("trackend",{touch:i[i.length-1].touch,timestamp:Date.now(),count:0,history:i}),delete this.touchHistory[t]}}function h(t){this.selective=t,this.touchHistory={},this.eventInput=new u,this.eventOutput=new u,u.setInputHandler(this,this.eventInput),u.setOutputHandler(this,this.eventOutput),this.eventInput.on("touchstart",o.bind(this)),this.eventInput.on("touchmove",n.bind(this)),this.eventInput.on("touchend",r.bind(this)),this.eventInput.on("touchcancel",r.bind(this)),this.eventInput.on("unpipe",a.bind(this))}var u=t("famous/core/EventHandler"),c=Date.now;h.prototype.track=function(t){this.touchHistory[t.identifier]=[t]},e.exports=h}),define("famous/inputs/TouchSync",["require","exports","module","./TouchTracker","famous/core/EventHandler"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._eventOutput=new h,this._touchTracker=new a,h.setOutputHandler(this,this._eventOutput),h.setInputHandler(this,this._touchTracker),this._touchTracker.on("trackstart",o.bind(this)),this._touchTracker.on("trackmove",n.bind(this)),this._touchTracker.on("trackend",r.bind(this)),this._payload={delta:null,position:null,velocity:null,clientX:void 0,clientY:void 0,count:0,touch:void 0},this._position=null}function o(t){var i,e;void 0!==this.options.direction?(this._position=0,i=0,e=0):(this._position=[0,0],i=[0,0],e=[0,0]);var s=this._payload;s.delta=e,s.position=this._position,s.velocity=i,s.clientX=t.x,s.clientY=t.y,s.count=t.count,s.touch=t.identifier,this._eventOutput.emit("start",s)}function n(t){var i=t.history,e=i[i.length-1],o=i[i.length-2],n=o.timestamp,r=e.timestamp,a=e.x-o.x,h=e.y-o.y;this.options.rails&&(Math.abs(a)>Math.abs(h)?h=0:a=0);var c,p,l=Math.max(r-n,u),f=a/l,d=h/l,m=this.options.scale;this.options.direction===s.DIRECTION_X?(p=m*a,c=m*f,this._position+=p):this.options.direction===s.DIRECTION_Y?(p=m*h,c=m*d,this._position+=p):(p=[m*a,m*h],c=[m*f,m*d],this._position[0]+=p[0],this._position[1]+=p[1]);var y=this._payload;y.delta=p,y.velocity=c,y.position=this._position,y.clientX=t.x,y.clientY=t.y,y.count=t.count,y.touch=t.identifier,this._eventOutput.emit("update",y)}function r(t){this._payload.count=t.count,this._eventOutput.emit("end",this._payload)}var a=t("./TouchTracker"),h=t("famous/core/EventHandler");s.DEFAULT_OPTIONS={direction:void 0,rails:!1,scale:1},s.DIRECTION_X=0,s.DIRECTION_Y=1;var u=8;s.prototype.setOptions=function(t){void 0!==t.direction&&(this.options.direction=t.direction),void 0!==t.rails&&(this.options.rails=t.rails),void 0!==t.scale&&(this.options.scale=t.scale)},s.prototype.getOptions=function(){return this.options},e.exports=s}),define("famous/modifiers/Draggable",["require","exports","module","famous/core/Transform","famous/transitions/Transitionable","famous/core/EventHandler","famous/math/Utilities","famous/inputs/GenericSync","famous/inputs/MouseSync","famous/inputs/TouchSync"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._positionState=new c([0,0]),this._differential=[0,0],this._active=!0,this.sync=new f(["mouse","touch"],{scale:this.options.scale}),this.eventOutput=new p,p.setInputHandler(this,this.sync),p.setOutputHandler(this,this.eventOutput),h.call(this)}function o(t){var i=this.options,e=i.projection,s=i.snapX,o=i.snapY,n=e&y.x?t[0]:0,r=e&y.y?t[1]:0;return s>0&&(n-=n%s),o>0&&(r-=r%o),[n,r]}function n(){this._active&&(this._positionState.isActive()&&this._positionState.halt(),this.eventOutput.emit("start",{position:this.getPosition()}))}function r(t){if(this._active){var i=this.options;this._differential=t.position;var e=o.call(this,this._differential);this._differential[0]-=e[0],this._differential[1]-=e[1];var s=this.getPosition();if(s[0]+=e[0],s[1]+=e[1],i.xRange){var n=[i.xRange[0]+.5*i.snapX,i.xRange[1]-.5*i.snapX];s[0]=_(s[0],n)}if(i.yRange){var r=[i.yRange[0]+.5*i.snapY,i.yRange[1]-.5*i.snapY];s[1]=_(s[1],r)}this.eventOutput.emit("update",{position:s})}}function a(){this._active&&this.eventOutput.emit("end",{position:this.getPosition()})}function h(){this.sync.on("start",n.bind(this)),this.sync.on("update",r.bind(this)),this.sync.on("end",a.bind(this))}var u=t("famous/core/Transform"),c=t("famous/transitions/Transitionable"),p=t("famous/core/EventHandler"),l=t("famous/math/Utilities"),f=t("famous/inputs/GenericSync"),d=t("famous/inputs/MouseSync"),m=t("famous/inputs/TouchSync");f.register({mouse:d,touch:m});var y={x:1,y:2};s.DIRECTION_X=y.x,s.DIRECTION_Y=y.y;var _=l.clamp;s.DEFAULT_OPTIONS={projection:y.x|y.y,scale:1,xRange:null,yRange:null,snapX:0,snapY:0,transition:{duration:0}},s.prototype.setOptions=function(t){var i=this.options;if(void 0!==t.projection){var e=t.projection;this.options.projection=0,["x","y"].forEach(function(t){-1!==e.indexOf(t)&&(i.projection|=y[t])})}void 0!==t.scale&&(i.scale=t.scale,this.sync.setOptions({scale:t.scale})),void 0!==t.xRange&&(i.xRange=t.xRange),void 0!==t.yRange&&(i.yRange=t.yRange),void 0!==t.snapX&&(i.snapX=t.snapX),void 0!==t.snapY&&(i.snapY=t.snapY)},s.prototype.getPosition=function(){return this._positionState.get()},s.prototype.setRelativePosition=function(t,i,e){var s=this.getPosition(),o=[s[0]+t[0],s[1]+t[1]];this.setPosition(o,i,e)},s.prototype.setPosition=function(t,i,e){this._positionState.isActive()&&this._positionState.halt(),this._positionState.set(t,i,e)},s.prototype.activate=function(){this._active=!0},s.prototype.deactivate=function(){this._active=!1},s.prototype.toggle=function(){this._active=!this._active},s.prototype.modify=function(t){var i=this.getPosition();return{transform:u.translate(i[0],i[1]),target:t}},e.exports=s}),define("famous/modifiers/Fader",["require","exports","module","famous/transitions/Transitionable","famous/core/OptionsManager"],function(t,i,e){function s(t,i){this.options=Object.create(s.DEFAULT_OPTIONS),this._optionsManager=new n(this.options),t&&this.setOptions(t),i||(i=0),this.transitionHelper=new o(i)}var o=t("famous/transitions/Transitionable"),n=t("famous/core/OptionsManager");s.DEFAULT_OPTIONS={cull:!1,transition:!0,pulseInTransition:!0,pulseOutTransition:!0},s.prototype.setOptions=function(t){return this._optionsManager.setOptions(t)},s.prototype.show=function(t,i){t=t||this.options.transition,this.set(1,t,i)},s.prototype.hide=function(t,i){t=t||this.options.transition,this.set(0,t,i)},s.prototype.set=function(t,i,e){this.halt(),this.transitionHelper.set(t,i,e)},s.prototype.halt=function(){this.transitionHelper.halt()},s.prototype.isVisible=function(){return this.transitionHelper.get()>0},s.prototype.modify=function(t){var i=this.transitionHelper.get();return this.options.cull&&!i?void 0:{opacity:i,target:t}},e.exports=s}),define("famous/modifiers/ModifierChain",["require","exports","module"],function(t,i,e){function s(){this._chain=[],arguments.length&&this.addModifier.apply(this,arguments)}s.prototype.addModifier=function(){Array.prototype.push.apply(this._chain,arguments)},s.prototype.removeModifier=function(t){var i=this._chain.indexOf(t);0>i||this._chain.splice(i,1)},s.prototype.modify=function(t){for(var i=this._chain,e=t,s=0;s<i.length;s++)e=i[s].modify(e);return e},e.exports=s}),define("famous/modifiers/StateModifier",["require","exports","module","famous/core/Modifier","famous/core/Transform","famous/transitions/Transitionable","famous/transitions/TransitionableTransform"],function(t,i,e){function s(t){this._transformState=new a(n.identity),this._opacityState=new r(1),this._originState=new r([0,0]),this._alignState=new r([0,0]),this._sizeState=new r([0,0]),this._modifier=new o({transform:this._transformState,opacity:this._opacityState,origin:null,align:null,size:null}),this._hasOrigin=!1,this._hasAlign=!1,this._hasSize=!1,t&&(t.transform&&this.setTransform(t.transform),void 0!==t.opacity&&this.setOpacity(t.opacity),t.origin&&this.setOrigin(t.origin),t.align&&this.setAlign(t.align),t.size&&this.setSize(t.size))}var o=t("famous/core/Modifier"),n=t("famous/core/Transform"),r=t("famous/transitions/Transitionable"),a=t("famous/transitions/TransitionableTransform");s.prototype.setTransform=function(t,i,e){return this._transformState.set(t,i,e),this},s.prototype.setOpacity=function(t,i,e){return this._opacityState.set(t,i,e),this},s.prototype.setOrigin=function(t,i,e){return null===t?(this._hasOrigin&&(this._modifier.originFrom(null),this._hasOrigin=!1),this):(this._hasOrigin||(this._hasOrigin=!0,this._modifier.originFrom(this._originState)),this._originState.set(t,i,e),this)},s.prototype.setAlign=function(t,i,e){return null===t?(this._hasAlign&&(this._modifier.alignFrom(null),this._hasAlign=!1),this):(this._hasAlign||(this._hasAlign=!0,this._modifier.alignFrom(this._alignState)),this._alignState.set(t,i,e),this)},s.prototype.setSize=function(t,i,e){return null===t?(this._hasSize&&(this._modifier.sizeFrom(null),this._hasSize=!1),this):(this._hasSize||(this._hasSize=!0,this._modifier.sizeFrom(this._sizeState)),this._sizeState.set(t,i,e),this)},s.prototype.halt=function(){this._transformState.halt(),this._opacityState.halt(),this._originState.halt(),this._alignState.halt(),this._sizeState.halt()},s.prototype.getTransform=function(){return this._transformState.get()},s.prototype.getFinalTransform=function(){return this._transformState.getFinal()},s.prototype.getOpacity=function(){return this._opacityState.get()},s.prototype.getOrigin=function(){return this._hasOrigin?this._originState.get():null},s.prototype.getAlign=function(){return this._hasAlign?this._alignState.get():null},s.prototype.getSize=function(){return this._hasSize?this._sizeState.get():null},s.prototype.modify=function(t){return this._modifier.modify(t)},e.exports=s}),define("famous/events/EventArbiter",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(t){this.dispatchers={},this.currMode=void 0,this.setMode(t)}var o=t("famous/core/EventHandler");s.prototype.setMode=function(t){if(t!==this.currMode){var i=this.currMode;this.dispatchers[this.currMode]&&this.dispatchers[this.currMode].trigger("unpipe"),this.currMode=t,this.dispatchers[t]&&this.dispatchers[t].emit("pipe"),this.emit("change",{from:i,to:t})}},s.prototype.forMode=function(t){return this.dispatchers[t]||(this.dispatchers[t]=new o),this.dispatchers[t]},s.prototype.emit=function(t,i){if(void 0===this.currMode)return!1;i||(i={});var e=this.dispatchers[this.currMode];return e?e.trigger(t,i):void 0},e.exports=s}),define("famous/events/EventFilter",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(t){o.call(this),this._condition=t}var o=t("famous/core/EventHandler");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.emit=function(t,i){return this._condition(t,i)?o.prototype.emit.apply(this,arguments):void 0},s.prototype.trigger=s.prototype.emit,e.exports=s}),define("famous/events/EventMapper",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(t){o.call(this),this._mappingFunction=t}var o=t("famous/core/EventHandler");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.subscribe=null,s.prototype.unsubscribe=null,s.prototype.emit=function(t,i){var e=this._mappingFunction.apply(this,arguments);e&&e.emit instanceof Function&&e.emit(t,i)},s.prototype.trigger=s.prototype.emit,e.exports=s}),define("famous/physics/PhysicsEngine",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this._particles=[],this._bodies=[],this._agents={},this._forces=[],this._constraints=[],this._buffer=0,this._prevTime=w(),this._isSleeping=!1,this._eventHandler=null,this._currAgentId=0,this._hasBodies=!1}function o(t){return t.applyForce?this._forces:t.applyConstraint?this._constraints:void 0}function n(t,i,e){return void 0===i&&(i=this.getParticlesAndBodies()),i instanceof Array||(i=[i]),this._agents[this._currAgentId]={agent:t,targets:i,source:e},o.call(this,t).push(this._currAgentId),this._currAgentId++}function r(t){return this._agents[t]}function a(t){var i=r.call(this,this._forces[t]);i.agent.applyForce(i.targets,i.source)}function h(){for(var t=this._forces.length-1;t>-1;t--)a.call(this,t)}function u(t,i){var e=this._agents[this._constraints[t]];return e.agent.applyConstraint(e.targets,e.source,i)}function c(t){for(var i=0;i<this.options.constraintSteps;){for(var e=this._constraints.length-1;e>-1;e--)u.call(this,e,t);i++}}function p(t,i){t.integrateVelocity(i)}function l(t,i){t.integrateAngularMomentum(i),t.updateAngularVelocity()}function f(t,i){t.integrateOrientation(i)}function d(t,i){t.integratePosition(i),t.emit("update",t)}function m(t){h.call(this,t),this.forEach(p,t),this.forEachBody(l,t),c.call(this,t),this.forEachBody(f,t),this.forEach(d,t)}function y(){var t=0,i=0;return this.forEach(function(e){i=e.getEnergy(),t+=i,i<e.sleepTolerance&&e.sleep()}),t}function _(){for(var t=0,i=this._forces.length-1;i>-1;i--)t+=this._forces[i].getEnergy()||0;return t}function g(){for(var t=0,i=this._constraints.length-1;i>-1;i--)t+=this._constraints[i].getEnergy()||0;return t}var v=t("famous/core/EventHandler"),O=17,T=1e3/120,S=17;s.DEFAULT_OPTIONS={constraintSteps:1,sleepTolerance:1e-7};var w=function(){return Date.now}();s.prototype.setOptions=function(t){for(var i in t)this.options[i]&&(this.options[i]=t[i])},s.prototype.addBody=function(t){return t._engine=this,t.isBody?(this._bodies.push(t),this._hasBodies=!0):this._particles.push(t),t},s.prototype.removeBody=function(t){var i=t.isBody?this._bodies:this._particles,e=i.indexOf(t);if(e>-1){for(var s=0;s<Object.keys(this._agents).length;s++)this.detachFrom(s,t);i.splice(e,1)}0===this.getBodies().length&&(this._hasBodies=!1)},s.prototype.attach=function(t,i,e){if(t instanceof Array){for(var s=[],o=0;o<t.length;o++)s[o]=n.call(this,t[o],i,e);return s}return n.call(this,t,i,e)},s.prototype.attachTo=function(t,i){r.call(this,t).targets.push(i)},s.prototype.detach=function(t){var i=this.getAgent(t),e=o.call(this,i),s=e.indexOf(t);e.splice(s,1),delete this._agents[t]},s.prototype.detachFrom=function(t,i){var e=r.call(this,t);if(e.source===i)this.detach(t);else{var s=e.targets,o=s.indexOf(i);o>-1&&s.splice(o,1)}},s.prototype.detachAll=function(){this._agents={},this._forces=[],this._constraints=[],this._currAgentId=0},s.prototype.getAgent=function(t){return r.call(this,t).agent},s.prototype.getParticles=function(){return this._particles},s.prototype.getBodies=function(){return this._bodies},s.prototype.getParticlesAndBodies=function(){return this.getParticles().concat(this.getBodies())},s.prototype.forEachParticle=function(t,i){for(var e=this.getParticles(),s=0,o=e.length;o>s;s++)t.call(this,e[s],i)},s.prototype.forEachBody=function(t,i){if(this._hasBodies)for(var e=this.getBodies(),s=0,o=e.length;o>s;s++)t.call(this,e[s],i)},s.prototype.forEach=function(t,i){this.forEachParticle(t,i),this.forEachBody(t,i)},s.prototype.getEnergy=function(){return y.call(this)+_.call(this)+g.call(this)},s.prototype.step=function(){var t=w(),i=t-this._prevTime;this._prevTime=t,T>i||(i>S&&(i=S),m.call(this,O))},s.prototype.isSleeping=function(){return this._isSleeping},s.prototype.sleep=function(){this.emit("end",this),this._isSleeping=!0},s.prototype.wake=function(){this._prevTime=w(),this.emit("start",this),this._isSleeping=!1},s.prototype.emit=function(t,i){null!==this._eventHandler&&this._eventHandler.emit(t,i)},s.prototype.on=function(t,i){null===this._eventHandler&&(this._eventHandler=new v),this._eventHandler.on(t,i)},e.exports=s}),define("famous/surfaces/CanvasSurface",["require","exports","module","famous/core/Surface"],function(t,i,e){function s(t){t&&t.canvasSize&&(this._canvasSize=t.canvasSize),o.apply(this,arguments),this._canvasSize||(this._canvasSize=this.getSize()),this._backBuffer=document.createElement("canvas"),this._canvasSize&&(this._backBuffer.width=this._canvasSize[0],this._backBuffer.height=this._canvasSize[1]),this._contextId=void 0}var o=t("famous/core/Surface");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.elementType="canvas",s.prototype.elementClass="famous-surface",s.prototype.setContent=function(){},s.prototype.deploy=function(t){this._canvasSize&&(t.width=this._canvasSize[0],t.height=this._canvasSize[1]),"2d"===this._contextId&&(t.getContext(this._contextId).drawImage(this._backBuffer,0,0),this._backBuffer.width=0,this._backBuffer.height=0)},s.prototype.recall=function(t){this.getSize();this._backBuffer.width=t.width,this._backBuffer.height=t.height,"2d"===this._contextId&&(this._backBuffer.getContext(this._contextId).drawImage(t,0,0),t.width=0,t.height=0)},s.prototype.getContext=function(t){return this._contextId=t,this._currTarget?this._currTarget.getContext(t):this._backBuffer.getContext(t)},s.prototype.setSize=function(t,i){o.prototype.setSize.apply(this,arguments),i&&(this._canvasSize=[i[0],i[1]]),this._currTarget&&(this._currTarget.width=this._canvasSize[0],this._currTarget.height=this._canvasSize[1])},e.exports=s}),define("famous/surfaces/ContainerSurface",["require","exports","module","famous/core/Surface","famous/core/Context"],function(t,i,e){function s(t){o.call(this,t),this._container=document.createElement("div"),this._container.classList.add("famous-group"),this._container.classList.add("famous-container-group"),this._shouldRecalculateSize=!1,this.context=new n(this._container),this.setContent(this._container)}var o=t("famous/core/Surface"),n=t("famous/core/Context");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.elementType="div",s.prototype.elementClass="famous-surface",s.prototype.add=function(){return this.context.add.apply(this.context,arguments)},s.prototype.render=function(){return this._sizeDirty&&(this._shouldRecalculateSize=!0),o.prototype.render.apply(this,arguments)},s.prototype.deploy=function(){return this._shouldRecalculateSize=!0,o.prototype.deploy.apply(this,arguments)},s.prototype.commit=function(){var t=this._size?[this._size[0],this._size[1]]:null,i=o.prototype.commit.apply(this,arguments);return(this._shouldRecalculateSize||t&&(this._size[0]!==t[0]||this._size[1]!==t[1]))&&(this.context.setSize(),this._shouldRecalculateSize=!1),this.context.update(),i},e.exports=s}),define("famous/surfaces/FormContainerSurface",["require","exports","module","./ContainerSurface"],function(t,i,e){function s(t){t&&(this._method=t.method||""),o.apply(this,arguments)}var o=t("./ContainerSurface");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.elementType="form",s.prototype.deploy=function(t){return this._method&&(t.method=this._method),o.prototype.deploy.apply(this,arguments)},e.exports=s}),define("famous/surfaces/ImageSurface",["require","exports","module","famous/core/Surface"],function(t,i,e){function s(){this._imageUrl=void 0,o.apply(this,arguments)}var o=t("famous/core/Surface");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.elementType="img",s.prototype.elementClass="famous-surface",s.prototype.setContent=function(t){this._imageUrl=t,this._contentDirty=!0},s.prototype.deploy=function(t){t.src=this._imageUrl||""},s.prototype.recall=function(t){t.src=""},e.exports=s}),define("famous/surfaces/InputSurface",["require","exports","module","famous/core/Surface"],function(t,i,e){function s(t){this._placeholder=t.placeholder||"",this._value=t.value||"",this._type=t.type||"text",this._name=t.name||"",o.apply(this,arguments),this.on("click",this.focus.bind(this)),window.addEventListener("click",function(t){t.target!==this._currTarget&&this.blur()}.bind(this))}var o=t("famous/core/Surface");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.elementType="input",s.prototype.elementClass="famous-surface",s.prototype.setPlaceholder=function(t){return this._placeholder=t,this._contentDirty=!0,this},s.prototype.focus=function(){return this._currTarget&&this._currTarget.focus(),this},s.prototype.blur=function(){return this._currTarget&&this._currTarget.blur(),this},s.prototype.setValue=function(t){return this._value=t,this._contentDirty=!0,this},s.prototype.setType=function(t){return this._type=t,this._contentDirty=!0,this},s.prototype.getValue=function(){return this._currTarget?this._currTarget.value:this._value},s.prototype.setName=function(t){return this._name=t,this._contentDirty=!0,this},s.prototype.getName=function(){return this._name},s.prototype.deploy=function(t){""!==this._placeholder&&(t.placeholder=this._placeholder),t.value=this._value,t.type=this._type,t.name=this._name},e.exports=s}),define("famous/surfaces/SubmitInputSurface",["require","exports","module","./InputSurface"],function(t,i,e){function s(t){o.apply(this,arguments),this._type="submit",t&&t.onClick&&this.setOnClick(t.onClick)}var o=t("./InputSurface");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.setOnClick=function(t){this.onClick=t},s.prototype.deploy=function(t){this.onclick&&(t.onClick=this.onClick),o.prototype.deploy.apply(this,arguments)},e.exports=s}),define("famous/surfaces/TextareaSurface",["require","exports","module","famous/core/Surface"],function(t,i,e){function s(t){this._placeholder=t.placeholder||"",this._value=t.value||"",this._name=t.name||"",this._wrap=t.wrap||"",this._cols=t.cols||"",this._rows=t.rows||"",o.apply(this,arguments),this.on("click",this.focus.bind(this))}var o=t("famous/core/Surface");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.elementType="textarea",s.prototype.elementClass="famous-surface",s.prototype.setPlaceholder=function(t){return this._placeholder=t,this._contentDirty=!0,this},s.prototype.focus=function(){return this._currTarget&&this._currTarget.focus(),this},s.prototype.blur=function(){return this._currTarget&&this._currTarget.blur(),this},s.prototype.setValue=function(t){return this._value=t,this._contentDirty=!0,this},s.prototype.getValue=function(){return this._currTarget?this._currTarget.value:this._value},s.prototype.setName=function(t){return this._name=t,this._contentDirty=!0,this},s.prototype.getName=function(){return this._name},s.prototype.setWrap=function(t){return this._wrap=t,this._contentDirty=!0,this},s.prototype.setColumns=function(t){return this._cols=t,this._contentDirty=!0,this},s.prototype.setRows=function(t){return this._rows=t,this._contentDirty=!0,this},s.prototype.deploy=function(t){""!==this._placeholder&&(t.placeholder=this._placeholder),""!==this._value&&(t.value=this._value),""!==this._name&&(t.name=this._name),""!==this._wrap&&(t.wrap=this._wrap),""!==this._cols&&(t.cols=this._cols),""!==this._rows&&(t.rows=this._rows)},e.exports=s}),define("famous/surfaces/VideoSurface",["require","exports","module","famous/core/Surface"],function(t,i,e){function s(t){this._videoUrl=void 0,this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),o.apply(this,arguments)}var o=t("famous/core/Surface");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={autoplay:!1},s.prototype.elementType="video",s.prototype.elementClass="famous-surface",s.prototype.setOptions=function(t){for(var i in s.DEFAULT_OPTIONS)void 0!==t[i]&&(this.options[i]=t[i])},s.prototype.setContent=function(t){this._videoUrl=t,this._contentDirty=!0},s.prototype.deploy=function(t){t.src=this._videoUrl,t.autoplay=this.options.autoplay},s.prototype.recall=function(t){t.src=""},e.exports=s}),define("famous/transitions/CachedMap",["require","exports","module"],function(t,i,e){function s(t){this._map=t||null,this._cachedOutput=null,this._cachedInput=Number.NaN}s.create=function(t){var i=new s(t);return i.get.bind(i)},s.prototype.get=function(t){return t!==this._cachedInput&&(this._cachedInput=t,this._cachedOutput=this._map(t)),this._cachedOutput},e.exports=s}),define("famous/transitions/Easing",["require","exports","module"],function(t,i,e){var s={inQuad:function(t){return t*t},outQuad:function(t){return-(t-=1)*t+1},inOutQuad:function(t){return(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1)},inCubic:function(t){return t*t*t},outCubic:function(t){return--t*t*t+1},inOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},inQuart:function(t){return t*t*t*t},outQuart:function(t){return-(--t*t*t*t-1)},inOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},inQuint:function(t){return t*t*t*t*t},outQuint:function(t){return--t*t*t*t*t+1},inOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},inSine:function(t){return-1*Math.cos(t*(Math.PI/2))+1},outSine:function(t){return Math.sin(t*(Math.PI/2))},inOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},inExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},outExpo:function(t){return 1===t?1:-Math.pow(2,-10*t)+1},inOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},inCirc:function(t){return-(Math.sqrt(1-t*t)-1)},outCirc:function(t){return Math.sqrt(1- --t*t)},inOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},inElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1===t?1:(e||(e=.3),i=e/(2*Math.PI)*Math.asin(1/s),-(s*Math.pow(2,10*(t-=1))*Math.sin(2*(t-i)*Math.PI/e)))},outElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1===t?1:(e||(e=.3),i=e/(2*Math.PI)*Math.asin(1/s),s*Math.pow(2,-10*t)*Math.sin(2*(t-i)*Math.PI/e)+1)},inOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:2===(t/=.5)?1:(e||(e=.3*1.5),i=e/(2*Math.PI)*Math.asin(1/s),1>t?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(t-i)*Math.PI/e):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(t-i)*Math.PI/e)*.5+1)},inBack:function(t,i){return void 0===i&&(i=1.70158),t*t*((i+1)*t-i)},outBack:function(t,i){return void 0===i&&(i=1.70158),--t*t*((i+1)*t+i)+1},inOutBack:function(t,i){return void 0===i&&(i=1.70158),(t/=.5)<1?.5*t*t*(((i*=1.525)+1)*t-i):.5*((t-=2)*t*(((i*=1.525)+1)*t+i)+2)},inBounce:function(t){return 1-s.outBounce(1-t)},outBounce:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},inOutBounce:function(t){return.5>t?.5*s.inBounce(2*t):.5*s.outBounce(2*t-1)+.5}};e.exports=s}),define("famous/physics/integrators/SymplecticEuler",["require","exports","module","famous/core/OptionsManager"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this._optionsManager=new o(this.options),t&&this.setOptions(t)}var o=t("famous/core/OptionsManager");s.DEFAULT_OPTIONS={velocityCap:void 0,angularVelocityCap:void 0},s.prototype.setOptions=function(t){this._optionsManager.patch(t)},s.prototype.getOptions=function(){return this._optionsManager.value()},s.prototype.integrateVelocity=function(t,i){var e=t.velocity,s=t.inverseMass,o=t.force;o.isZero()||(e.add(o.mult(i*s)).put(e),o.clear())},s.prototype.integratePosition=function(t,i){var e=t.position,s=t.velocity;this.options.velocityCap&&s.cap(this.options.velocityCap).put(s),e.add(s.mult(i)).put(e)},s.prototype.integrateAngularMomentum=function(t,i){var e=t.angularMomentum,s=t.torque;s.isZero()||(this.options.angularVelocityCap&&s.cap(this.options.angularVelocityCap).put(s),e.add(s.mult(i)).put(e),s.clear())},s.prototype.integrateOrientation=function(t,i){var e=t.orientation,s=t.angularVelocity;
|
|
s.isZero()||e.add(e.multiply(s).scalarMultiply(.5*i)).put(e)},e.exports=s}),define("famous/physics/bodies/Particle",["require","exports","module","famous/math/Vector","famous/core/Transform","famous/core/EventHandler","../integrators/SymplecticEuler"],function(t,i,e){function s(t){t=t||{},this.position=new n,this.velocity=new n,this.force=new n;var i=s.DEFAULT_OPTIONS;this.setPosition(t.position||i.position),this.setVelocity(t.velocity||i.velocity),this.force.set(t.force||[0,0,0]),this.mass=void 0!==t.mass?t.mass:i.mass,this.axis=void 0!==t.axis?t.axis:i.axis,this.inverseMass=1/this.mass,this._isSleeping=!1,this._engine=null,this._eventOutput=null,this._positionGetter=null,this.transform=r.identity.slice(),this._spec={transform:this.transform,target:null}}function o(){this._eventOutput=new a,this._eventOutput.bindThis(this),a.setOutputHandler(this,this._eventOutput)}var n=t("famous/math/Vector"),r=t("famous/core/Transform"),a=t("famous/core/EventHandler"),h=t("../integrators/SymplecticEuler");s.DEFAULT_OPTIONS={position:[0,0,0],velocity:[0,0,0],mass:1,axis:void 0},s.SLEEP_TOLERANCE=1e-7,s.AXES={X:0,Y:1,Z:2},s.INTEGRATOR=new h;var u={start:"start",update:"update",end:"end"},c=function(){return Date.now}();s.prototype.sleep=function(){this._isSleeping||(this.emit(u.end,this),this._isSleeping=!0)},s.prototype.wake=function(){this._isSleeping&&(this.emit(u.start,this),this._isSleeping=!1,this._prevTime=c())},s.prototype.isBody=!1,s.prototype.setPosition=function(t){this.position.set(t)},s.prototype.setPosition1D=function(t){this.position.x=t},s.prototype.getPosition=function(){return this._positionGetter instanceof Function&&this.setPosition(this._positionGetter()),this._engine.step(),this.position.get()},s.prototype.getPosition1D=function(){return this._engine.step(),this.position.x},s.prototype.positionFrom=function(t){this._positionGetter=t},s.prototype.setVelocity=function(t){this.velocity.set(t),this.wake()},s.prototype.setVelocity1D=function(t){this.velocity.x=t,this.wake()},s.prototype.getVelocity=function(){return this.velocity.get()},s.prototype.getVelocity1D=function(){return this.velocity.x},s.prototype.setMass=function(t){this.mass=t,this.inverseMass=1/t},s.prototype.getMass=function(){return this.mass},s.prototype.reset=function(t,i){this.setPosition(t||[0,0,0]),this.setVelocity(i||[0,0,0])},s.prototype.applyForce=function(t){t.isZero()||(this.force.add(t).put(this.force),this.wake())},s.prototype.applyImpulse=function(t){if(!t.isZero()){var i=this.velocity;i.add(t.mult(this.inverseMass)).put(i)}},s.prototype.integrateVelocity=function(t){s.INTEGRATOR.integrateVelocity(this,t)},s.prototype.integratePosition=function(t){s.INTEGRATOR.integratePosition(this,t)},s.prototype._integrate=function(t){this.integrateVelocity(t),this.integratePosition(t)},s.prototype.getEnergy=function(){return.5*this.mass*this.velocity.normSquared()},s.prototype.getTransform=function(){this._engine.step();var t=this.position,i=this.axis,e=this.transform;return void 0!==i&&(i&~s.AXES.X&&(t.x=0),i&~s.AXES.Y&&(t.y=0),i&~s.AXES.Z&&(t.z=0)),e[12]=t.x,e[13]=t.y,e[14]=t.z,e},s.prototype.modify=function(t){var i=this._spec;return i.transform=this.getTransform(),i.target=t,i},s.prototype.emit=function(t,i){this._eventOutput&&this._eventOutput.emit(t,i)},s.prototype.on=function(){return o.call(this),this.on.apply(this,arguments)},s.prototype.removeListener=function(){return o.call(this),this.removeListener.apply(this,arguments)},s.prototype.pipe=function(){return o.call(this),this.pipe.apply(this,arguments)},s.prototype.unpipe=function(){return o.call(this),this.unpipe.apply(this,arguments)},e.exports=s}),define("famous/physics/constraints/Constraint",["require","exports","module","famous/core/EventHandler"],function(t,i,e){function s(){this.options=this.options||{},this._energy=0,this._eventOutput=null}function o(){this._eventOutput=new n,this._eventOutput.bindThis(this),n.setOutputHandler(this,this._eventOutput)}var n=t("famous/core/EventHandler");s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},s.prototype.applyConstraint=function(){},s.prototype.getEnergy=function(){return this._energy},s.prototype.setEnergy=function(t){this._energy=t},s.prototype.on=function(){return o.call(this),this.on.apply(this,arguments)},s.prototype.addListener=function(){return o.call(this),this.addListener.apply(this,arguments)},s.prototype.pipe=function(){return o.call(this),this.pipe.apply(this,arguments)},s.prototype.removeListener=function(){return this.removeListener.apply(this,arguments)},s.prototype.unpipe=function(){return this.unpipe.apply(this,arguments)},e.exports=s}),define("famous/physics/constraints/Snap",["require","exports","module","./Constraint","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(this.constructor.DEFAULT_OPTIONS),t&&this.setOptions(t),this.pDiff=new r,this.vDiff=new r,this.impulse1=new r,this.impulse2=new r,n.call(this)}function o(t,i,e){return Math.abs(t.dot(i)/e)}var n=t("./Constraint"),r=t("famous/math/Vector");s.prototype=Object.create(n.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={period:300,dampingRatio:.1,length:0,anchor:void 0};var a=Math.PI;s.prototype.setOptions=function(t){void 0!==t.anchor&&(t.anchor instanceof r&&(this.options.anchor=t.anchor),t.anchor.position instanceof r&&(this.options.anchor=t.anchor.position),t.anchor instanceof Array&&(this.options.anchor=new r(t.anchor))),void 0!==t.length&&(this.options.length=t.length),void 0!==t.dampingRatio&&(this.options.dampingRatio=t.dampingRatio),void 0!==t.period&&(this.options.period=t.period)},s.prototype.setAnchor=function(t){void 0!==this.options.anchor&&(this.options.anchor=new r),this.options.anchor.set(t)},s.prototype.getEnergy=function(t,i){var e=this.options,s=e.length,o=e.anchor||i.position,n=Math.pow(2*a/e.period,2),r=o.sub(t.position).norm()-s;return.5*n*r*r},s.prototype.applyConstraint=function(t,i,e){for(var s=this.options,n=this.pDiff,r=this.vDiff,h=this.impulse1,u=this.impulse2,c=s.length,p=s.anchor||i.position,l=s.period,f=s.dampingRatio,d=0;d<t.length;d++){var m=t[d],y=m.position,_=m.velocity,g=m.mass,v=m.inverseMass;n.set(y.sub(p));var O,T=n.norm()-c;if(i){var S=i.inverseMass,w=i.velocity;r.set(_.sub(w)),O=1/(v+S)}else r.set(_),O=g;var b,x;if(0===this.options.period)b=0,x=1;else{var E=4*O*a*a/(l*l),I=4*O*a*f/l;x=e*E/(I+e*E),b=1/(I+e*E)}var M=x/e*T;n.normalize(-M).sub(r).mult(e/(b+e/O)).put(h),m.applyImpulse(h),i&&(h.mult(-1).put(u),i.applyImpulse(u)),this.setEnergy(o(h,n,e))}},e.exports=s}),define("famous/transitions/SnapTransition",["require","exports","module","famous/physics/PhysicsEngine","famous/physics/bodies/Particle","famous/physics/constraints/Snap","famous/math/Vector"],function(t,i,e){function s(t){t=t||0,this.endState=new v(t),this.initState=new v,this._dimensions=1,this._restTolerance=1e-10,this._absRestTolerance=this._restTolerance,this._callback=void 0,this.PE=new y,this.particle=new _,this.spring=new g({anchor:this.endState}),this.PE.addBody(this.particle),this.PE.attach(this.spring,this.particle)}function o(){return this.particle.getEnergy()+this.spring.getEnergy(this.particle)}function n(){var t=this.endState.sub(this.initState).normSquared();this._absRestTolerance=0===t?this._restTolerance:this._restTolerance*t}function r(t){this.endState.set(t),n.call(this)}function a(){this.PE.wake()}function h(){this.PE.sleep()}function u(t){this.particle.position.set(t)}function c(t){this.particle.velocity.set(t)}function p(){return 0===this._dimensions?this.particle.getPosition1D():this.particle.getPosition()}function l(){return 0===this._dimensions?this.particle.getVelocity1D():this.particle.getVelocity()}function f(t){this._callback=t}function d(t){var i=s.DEFAULT_OPTIONS;void 0===t.period&&(t.period=i.period),void 0===t.dampingRatio&&(t.dampingRatio=i.dampingRatio),void 0===t.velocity&&(t.velocity=i.velocity),this.spring.setOptions({period:t.period,dampingRatio:t.dampingRatio}),c.call(this,t.velocity)}function m(){if(this.PE.isSleeping()){if(this._callback){var t=this._callback;this._callback=void 0,t()}}else o.call(this)<this._absRestTolerance&&(u.call(this,this.endState),c.call(this,[0,0,0]),h.call(this))}var y=t("famous/physics/PhysicsEngine"),_=t("famous/physics/bodies/Particle"),g=t("famous/physics/constraints/Snap"),v=t("famous/math/Vector");s.SUPPORTS_MULTIPLE=3,s.DEFAULT_OPTIONS={period:100,dampingRatio:.2,velocity:0},s.prototype.reset=function(t,i){this._dimensions=t instanceof Array?t.length:0,this.initState.set(t),u.call(this,t),r.call(this,t),i&&c.call(this,i),f.call(this,void 0)},s.prototype.getVelocity=function(){return l.call(this)},s.prototype.setVelocity=function(t){this.call(this,c(t))},s.prototype.isActive=function(){return!this.PE.isSleeping()},s.prototype.halt=function(){this.set(this.get())},s.prototype.get=function(){return m.call(this),p.call(this)},s.prototype.set=function(t,i,e){return i?(this._dimensions=t instanceof Array?t.length:0,a.call(this),d.call(this,i),r.call(this,t),void f.call(this,e)):(this.reset(t),void(e&&e()))},e.exports=s}),define("famous/physics/forces/Force",["require","exports","module","famous/math/Vector","famous/core/EventHandler"],function(t,i,e){function s(t){this.force=new n(t),this._energy=0,this._eventOutput=null}function o(){this._eventOutput=new r,this._eventOutput.bindThis(this),r.setOutputHandler(this,this._eventOutput)}var n=t("famous/math/Vector"),r=t("famous/core/EventHandler");s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},s.prototype.applyForce=function(t){t.applyForce(this.force)},s.prototype.getEnergy=function(){return this._energy},s.prototype.setEnergy=function(t){this._energy=t},s.prototype.on=function(){return o.call(this),this.on.apply(this,arguments)},s.prototype.addListener=function(){return o.call(this),this.addListener.apply(this,arguments)},s.prototype.pipe=function(){return o.call(this),this.pipe.apply(this,arguments)},s.prototype.removeListener=function(){return this.removeListener.apply(this,arguments)},s.prototype.unpipe=function(){return this.unpipe.apply(this,arguments)},e.exports=s}),define("famous/physics/forces/Spring",["require","exports","module","./Force","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(this.constructor.DEFAULT_OPTIONS),t&&this.setOptions(t),this.disp=new c(0,0,0),h.call(this),u.call(this)}function o(t){this.forceFunction=t}function n(){var t=this.options;t.stiffness=Math.pow(2*p/t.period,2)}function r(){var t=this.options;t.damping=4*p*t.dampingRatio/t.period}function a(t,i){return.5*t*i*i}function h(){o.call(this,this.options.forceFunction),n.call(this),r.call(this)}var u=t("./Force"),c=t("famous/math/Vector");s.prototype=Object.create(u.prototype),s.prototype.constructor=s;var p=Math.PI;s.FORCE_FUNCTIONS={FENE:function(t,i){var e=.99*i,s=Math.max(Math.min(t,e),-e);return s/(1-s*s/(i*i))},HOOK:function(t){return t}},s.DEFAULT_OPTIONS={period:300,dampingRatio:.1,length:0,maxLength:1/0,anchor:void 0,forceFunction:s.FORCE_FUNCTIONS.HOOK},s.prototype.setOptions=function(t){void 0!==t.anchor&&(t.anchor.position instanceof c&&(this.options.anchor=t.anchor.position),t.anchor instanceof c&&(this.options.anchor=t.anchor),t.anchor instanceof Array&&(this.options.anchor=new c(t.anchor))),void 0!==t.period&&(this.options.period=t.period),void 0!==t.dampingRatio&&(this.options.dampingRatio=t.dampingRatio),void 0!==t.length&&(this.options.length=t.length),void 0!==t.forceFunction&&(this.options.forceFunction=t.forceFunction),void 0!==t.maxLength&&(this.options.maxLength=t.maxLength),h.call(this)},s.prototype.applyForce=function(t,i){for(var e=this.force,s=this.disp,o=this.options,n=o.stiffness,r=o.damping,h=o.length,u=o.maxLength,c=o.anchor||i.position,p=0;p<t.length;p++){var l=t[p],f=l.position,d=l.velocity;c.sub(f).put(s);var m=s.norm()-h;if(0===m)return;var y=l.mass;n*=y,r*=y,s.normalize(n*this.forceFunction(m,u)).put(e),r&&(i?e.add(d.sub(i.velocity).mult(-r)).put(e):e.add(d.mult(-r)).put(e)),l.applyForce(e),i&&i.applyForce(e.mult(-1)),this.setEnergy(a(n,m))}},s.prototype.getEnergy=function(t){var i=this.options,e=i.length,s=i.anchor,o=i.stiffness,n=s.sub(t.position).norm()-e;return.5*o*n*n},s.prototype.setAnchor=function(t){this.options.anchor||(this.options.anchor=new c),this.options.anchor.set(t)},e.exports=s}),define("famous/transitions/SpringTransition",["require","exports","module","famous/physics/PhysicsEngine","famous/physics/bodies/Particle","famous/physics/forces/Spring","famous/math/Vector"],function(t,i,e){function s(t){t=t||0,this.endState=new v(t),this.initState=new v,this._dimensions=void 0,this._restTolerance=1e-10,this._absRestTolerance=this._restTolerance,this._callback=void 0,this.PE=new y,this.spring=new g({anchor:this.endState}),this.particle=new _,this.PE.addBody(this.particle),this.PE.attach(this.spring,this.particle)}function o(){return this.particle.getEnergy()+this.spring.getEnergy(this.particle)}function n(t){this.particle.setPosition(t)}function r(t){this.particle.setVelocity(t)}function a(){return 0===this._dimensions?this.particle.getPosition1D():this.particle.getPosition()}function h(){return 0===this._dimensions?this.particle.getVelocity1D():this.particle.getVelocity()}function u(t){this._callback=t}function c(){this.PE.wake()}function p(){this.PE.sleep()}function l(){if(this.PE.isSleeping()){if(this._callback){var t=this._callback;this._callback=void 0,t()}}else o.call(this)<this._absRestTolerance&&(n.call(this,this.endState),r.call(this,[0,0,0]),p.call(this))}function f(t){var i=s.DEFAULT_OPTIONS;void 0===t.period&&(t.period=i.period),void 0===t.dampingRatio&&(t.dampingRatio=i.dampingRatio),void 0===t.velocity&&(t.velocity=i.velocity),t.period<150&&(t.period=150,console.warn("The period of a SpringTransition is capped at 150 ms. Use a SnapTransition for faster transitions")),this.spring.setOptions({period:t.period,dampingRatio:t.dampingRatio}),r.call(this,t.velocity)}function d(){var t=this.endState.sub(this.initState).normSquared();this._absRestTolerance=0===t?this._restTolerance:this._restTolerance*t}function m(t){this.endState.set(t),d.call(this)}var y=t("famous/physics/PhysicsEngine"),_=t("famous/physics/bodies/Particle"),g=t("famous/physics/forces/Spring"),v=t("famous/math/Vector");s.SUPPORTS_MULTIPLE=3,s.DEFAULT_OPTIONS={period:300,dampingRatio:.5,velocity:0},s.prototype.reset=function(t,i){this._dimensions=t instanceof Array?t.length:0,this.initState.set(t),n.call(this,t),m.call(this,t),i&&r.call(this,i),u.call(this,void 0)},s.prototype.getVelocity=function(){return h.call(this)},s.prototype.setVelocity=function(t){this.call(this,r(t))},s.prototype.isActive=function(){return!this.PE.isSleeping()},s.prototype.halt=function(){this.set(this.get())},s.prototype.get=function(){return l.call(this),a.call(this)},s.prototype.set=function(t,i,e){return i?(this._dimensions=t instanceof Array?t.length:0,c.call(this),f.call(this,i),m.call(this,t),void u.call(this,e)):(this.reset(t),void(e&&e()))},e.exports=s}),define("famous/physics/constraints/Wall",["require","exports","module","./Constraint","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this.diff=new u,this.impulse=new u,h.call(this)}function o(t,i){return i.dot(t)}function n(t){var i=this.options.normal,e=this.options.distance;return t.dot(i)+e}function r(t,i,e){var o=t.position,n=t.velocity,r=t.mass,a=this.options.normal,h=this.options.onContact,u=this.options.restitution,c=this.impulse,p=this.options.drift,l=-this.options.slop,f=0;if(this._eventOutput){var d={particle:t,wall:this,overlap:i,normal:a};this._eventOutput.emit("preCollision",d),this._eventOutput.emit("collision",d)}switch(h){case s.ON_CONTACT.REFLECT:var m=l>i?-((1+u)*a.dot(n)+p/e*(i-l))/(r*e+f):-((1+u)*a.dot(n))/(r*e+f);c.set(a.mult(e*m)),t.applyImpulse(c),t.setPosition(o.add(a.mult(-i)))}this._eventOutput&&this._eventOutput.emit("postCollision",d)}function a(t,i){var e=this.options.onContact,o=t.position,n=this.options.normal;e===s.ON_CONTACT.REFLECT&&t.setPosition(o.add(n.mult(-i)))}var h=t("./Constraint"),u=t("famous/math/Vector");s.prototype=Object.create(h.prototype),s.prototype.constructor=s,s.ON_CONTACT={REFLECT:0,SILENT:1},s.DEFAULT_OPTIONS={restitution:.5,drift:.5,slop:0,normal:[1,0,0],distance:0,onContact:s.ON_CONTACT.REFLECT},s.prototype.setOptions=function(t){void 0!==t.normal&&(t.normal instanceof u&&(this.options.normal=t.normal.clone()),t.normal instanceof Array&&(this.options.normal=new u(t.normal))),void 0!==t.restitution&&(this.options.restitution=t.restitution),void 0!==t.drift&&(this.options.drift=t.drift),void 0!==t.slop&&(this.options.slop=t.slop),void 0!==t.distance&&(this.options.distance=t.distance),void 0!==t.onContact&&(this.options.onContact=t.onContact)},s.prototype.applyConstraint=function(t,i,e){for(var s=this.options.normal,h=0;h<t.length;h++){var u=t[h],c=u.position,p=u.velocity,l=u.radius||0,f=n.call(this,c.add(s.mult(-l))),d=o.call(this,s,p);0>=f&&(0>d?r.call(this,u,f,e):a.call(this,u,f,e))}},e.exports=s}),define("famous/transitions/WallTransition",["require","exports","module","famous/physics/PhysicsEngine","famous/physics/bodies/Particle","famous/physics/forces/Spring","famous/physics/constraints/Wall","famous/math/Vector"],function(t,i,e){function s(t){t=t||0,this.endState=new O(t),this.initState=new O,this.spring=new g({anchor:this.endState}),this.wall=new v,this._restTolerance=1e-10,this._dimensions=1,this._absRestTolerance=this._restTolerance,this._callback=void 0,this.PE=new y,this.particle=new _,this.PE.addBody(this.particle),this.PE.attach([this.wall,this.spring],this.particle)}function o(){return this.particle.getEnergy()+this.spring.getEnergy(this.particle)}function n(){var t=this.endState.sub(this.initState).normSquared();this._absRestTolerance=0===t?this._restTolerance:this._restTolerance*t}function r(){this.PE.wake()}function a(){this.PE.sleep()}function h(t){this.endState.set(t);var i=this.endState.sub(this.initState).norm();this.wall.setOptions({distance:this.endState.norm(),normal:0===i?this.particle.velocity.normalize(-1):this.endState.sub(this.initState).normalize(-1)}),n.call(this)}function u(t){this.particle.position.set(t)}function c(t){this.particle.velocity.set(t)}function p(){return 0===this._dimensions?this.particle.getPosition1D():this.particle.getPosition()}function l(){return 0===this._dimensions?this.particle.getVelocity1D():this.particle.getVelocity()}function f(t){this._callback=t}function d(){if(this.PE.isSleeping()){if(this._callback){var t=this._callback;this._callback=void 0,t()}}else{var i=o.call(this);i<this._absRestTolerance&&(a.call(this),u.call(this,this.endState),c.call(this,[0,0,0]))}}function m(t){var i=s.DEFAULT_OPTIONS;void 0===t.period&&(t.period=i.period),void 0===t.dampingRatio&&(t.dampingRatio=i.dampingRatio),void 0===t.velocity&&(t.velocity=i.velocity),void 0===t.restitution&&(t.restitution=i.restitution),this.spring.setOptions({period:t.period,dampingRatio:t.dampingRatio}),this.wall.setOptions({restitution:t.restitution}),c.call(this,t.velocity)}var y=t("famous/physics/PhysicsEngine"),_=t("famous/physics/bodies/Particle"),g=t("famous/physics/forces/Spring"),v=t("famous/physics/constraints/Wall"),O=t("famous/math/Vector");s.SUPPORTS_MULTIPLE=3,s.DEFAULT_OPTIONS={period:300,dampingRatio:.5,velocity:0,resitution:.5},s.prototype.reset=function(t,i){this._dimensions=t instanceof Array?t.length:0,this.initState.set(t),u.call(this,t),i&&c.call(this,i),h.call(this,t),f.call(this,void 0)},s.prototype.getVelocity=function(){return l.call(this)},s.prototype.setVelocity=function(t){this.call(this,c(t))},s.prototype.isActive=function(){return!this.PE.isSleeping()},s.prototype.halt=function(){this.set(this.get())},s.prototype.get=function(){return d.call(this),p.call(this)},s.prototype.set=function(t,i,e){return i?(this._dimensions=t instanceof Array?t.length:0,r.call(this),m.call(this,i),h.call(this,t),void f.call(this,e)):(this.reset(t),void(e&&e()))},e.exports=s}),define("famous/utilities/KeyCodes",["require","exports","module"],function(t,i,e){var s={0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:97,b:98,c:99,d:100,e:101,f:102,g:103,h:104,i:105,j:106,k:107,l:108,m:109,n:110,o:111,p:112,q:113,r:114,s:115,t:116,u:117,v:118,w:119,x:120,y:121,z:122,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,ENTER:13,LEFT_ARROW:37,RIGHT_ARROW:39,UP_ARROW:38,DOWN_ARROW:40,SPACE:32,SHIFT:16,TAB:9};e.exports=s}),define("famous/utilities/Timer",["require","exports","module","famous/core/Engine"],function(t,i,e){function s(t){return c.on(p,t),t}function o(t,i){var e=l(),o=function(){var s=l();s-e>=i&&(t.apply(this,arguments),c.removeListener(p,o))};return s(o)}function n(t,i){var e=l(),o=function(){var s=l();s-e>=i&&(t.apply(this,arguments),e=l())};return s(o)}function r(t,i){if(void 0===i)return void 0;var e=function(){i--,0>=i&&(t.apply(this,arguments),h(e))};return s(e)}function a(t,i){i=i||1;var e=i,o=function(){i--,0>=i&&(t.apply(this,arguments),i=e)};return s(o)}function h(t){c.removeListener(p,t)}function u(t,i){var e,s,n,r,a;return function(){s=this,a=arguments,n=l();var u=function(){var h=l-n;i>h?e=o(u,i-h):(e=null,r=t.apply(s,a))};return h(e),e=o(u,i),r}}var c=t("famous/core/Engine"),p="prerender",l=window.performance?function(){return window.performance.now()}:function(){return Date.now()};e.exports={setTimeout:o,setInterval:n,debounce:u,after:r,every:a,clear:h}}),define("famous/views/ContextualView",["require","exports","module","famous/core/Entity","famous/core/Transform","famous/core/EventHandler","famous/core/OptionsManager"],function(t,i,e){function s(t){this.options=Object.create(this.constructor.DEFAULT_OPTIONS||s.DEFAULT_OPTIONS),this._optionsManager=new r(this.options),t&&this.setOptions(t),this._eventInput=new n,this._eventOutput=new n,n.setInputHandler(this,this._eventInput),n.setOutputHandler(this,this._eventOutput),this._id=o.register(this)}var o=t("famous/core/Entity"),n=(t("famous/core/Transform"),t("famous/core/EventHandler")),r=t("famous/core/OptionsManager");s.DEFAULT_OPTIONS={},s.prototype.setOptions=function(t){return this._optionsManager.setOptions(t)},s.prototype.getOptions=function(){return this._optionsManager.getOptions()},s.prototype.render=function(){return this._id},s.prototype.commit=function(){},e.exports=s}),define("famous/views/SequentialLayout",["require","exports","module","famous/core/OptionsManager","famous/core/Transform","famous/core/ViewSequence","famous/utilities/Utility"],function(t,i,e){function s(t){this._items=null,this._size=null,this._outputFunction=s.DEFAULT_OUTPUT_FUNCTION,this.options=Object.create(this.constructor.DEFAULT_OPTIONS),this.optionsManager=new o(this.options),this._itemsCache=[],this._outputCache={size:null,target:this._itemsCache},t&&this.setOptions(t)}var o=t("famous/core/OptionsManager"),n=t("famous/core/Transform"),r=t("famous/core/ViewSequence"),a=t("famous/utilities/Utility");s.DEFAULT_OPTIONS={direction:a.Direction.Y,itemSpacing:0,defaultItemSize:[50,50]},s.DEFAULT_OUTPUT_FUNCTION=function(t,i){var e=this.options.direction===a.Direction.X?n.translate(i,0):n.translate(0,i);return{transform:e,target:t.render()}},s.prototype.getSize=function(){return this._size||this.render(),this._size},s.prototype.sequenceFrom=function(t){return t instanceof Array&&(t=new r(t)),this._items=t,this},s.prototype.setOptions=function(){return this.optionsManager.setOptions.apply(this.optionsManager,arguments),this},s.prototype.setOutputFunction=function(t){return this._outputFunction=t,this},s.prototype.render=function(){for(var t=0,i=0,e=this.options.direction===a.Direction.X?0:1,s=this.options.direction===a.Direction.X?1:0,o=this._items,n=this._itemsCache,r=0;o;){var h=o.get();if(!h)break;var u;h&&h.getSize&&(u=h.getSize()),u||(u=this.options.defaultItemSize),u[s]!==!0&&(i=Math.max(i,u[s]));var c=this._outputFunction.call(this,h,t,r);n[r]=c,u[e]&&u[e]!==!0&&(t+=u[e]+this.options.itemSpacing),o=o.getNext(),r++}return this._itemsCache.splice(r),i||(i=void 0),this._size||(this._size=[0,0]),this._size[e]=t-this.options.itemSpacing,this._size[s]=i,this._outputCache.size=this.getSize(),this._outputCache},e.exports=s}),define("famous/views/Deck",["require","exports","module","famous/core/Transform","famous/core/OptionsManager","famous/transitions/Transitionable","famous/utilities/Utility","./SequentialLayout"],function(t,i,e){function s(){c.apply(this,arguments),this.state=new h(0),this._isOpen=!1,this.setOutputFunction(function(t,i,e){var s=o.call(this),n=this.options.direction===u.Direction.X?r.translate(s*i,0,.001*(s-1)*i):r.translate(0,s*i,.001*(s-1)*i),a=t.render();if(this.options.stackRotation){var h=this.options.stackRotation*e*(1-s);a={transform:r.rotateZ(h),origin:[.5,.5],target:a}}return{transform:n,size:t.getSize(),target:a}})}function o(t){return t?this._isOpen?1:0:this.state.get()}function n(t,i,e){this.state.halt(),this.state.set(t,i,e)}var r=t("famous/core/Transform"),a=t("famous/core/OptionsManager"),h=t("famous/transitions/Transitionable"),u=t("famous/utilities/Utility"),c=t("./SequentialLayout");s.prototype=Object.create(c.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS=a.patch(c.DEFAULT_OPTIONS,{transition:{curve:"easeOutBounce",duration:500},stackRotation:0}),s.prototype.getSize=function(){var t=c.prototype.getSize.apply(this,arguments),i=this._items?this._items.get().getSize():[0,0];i||(i=[0,0]);var e=o.call(this),s=1-e;return[i[0]*s+t[0]*e,i[1]*s+t[1]*e]},s.prototype.isOpen=function(){return this._isOpen},s.prototype.open=function(t){this._isOpen=!0,n.call(this,1,this.options.transition,t)},s.prototype.close=function(t){this._isOpen=!1,n.call(this,0,this.options.transition,t)},s.prototype.toggle=function(t){this._isOpen?this.close(t):this.open(t)},e.exports=s}),define("famous/views/RenderController",["require","exports","module","famous/core/Modifier","famous/core/RenderNode","famous/core/Transform","famous/transitions/Transitionable","famous/core/View"],function(t,i,e){function s(){u.apply(this,arguments),this._showing=-1,this._outgoingRenderables=[],this._nextRenderable=null,this._renderables=[],this._nodes=[],this._modifiers=[],this._states=[],this.inTransformMap=s.DefaultMap.transform,this.inOpacityMap=s.DefaultMap.opacity,this.inOriginMap=s.DefaultMap.origin,this.outTransformMap=s.DefaultMap.transform,this.outOpacityMap=s.DefaultMap.opacity,this.outOriginMap=s.DefaultMap.origin,this._output=[]}function o(t,i){return t(i.get())}var n=t("famous/core/Modifier"),r=t("famous/core/RenderNode"),a=t("famous/core/Transform"),h=t("famous/transitions/Transitionable"),u=t("famous/core/View");s.prototype=Object.create(u.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={inTransition:!0,outTransition:!0,overlap:!0},s.DefaultMap={transform:function(){return a.identity},opacity:function(t){return t},origin:null},s.prototype.inTransformFrom=function(t){if(t instanceof Function)this.inTransformMap=t;else{if(!t||!t.get)throw Error("inTransformFrom takes only function or getter object");this.inTransformMap=t.get.bind(t)}return this},s.prototype.inOpacityFrom=function(t){if(t instanceof Function)this.inOpacityMap=t;else{if(!t||!t.get)throw Error("inOpacityFrom takes only function or getter object");this.inOpacityMap=t.get.bind(t)}return this},s.prototype.inOriginFrom=function(t){if(t instanceof Function)this.inOriginMap=t;else{if(!t||!t.get)throw Error("inOriginFrom takes only function or getter object");this.inOriginMap=t.get.bind(t)}return this},s.prototype.outTransformFrom=function(t){if(t instanceof Function)this.outTransformMap=t;else{if(!t||!t.get)throw Error("inTransformFrom takes only function or getter object");this.outTransformMap=t.get.bind(t)}return this},s.prototype.outOpacityFrom=function(t){if(t instanceof Function)this.outOpacityMap=t;else{if(!t||!t.get)throw Error("inOpacityFrom takes only function or getter object");this.outOpacityMap=t.get.bind(t)}return this},s.prototype.outOriginFrom=function(t){if(t instanceof Function)this.outOriginMap=t;else{if(!t||!t.get)throw Error("inOriginFrom takes only function or getter object");this.outOriginMap=t.get.bind(t)}return this},s.prototype.show=function(t,i,e){if(!t)return this.hide(e);if(i instanceof Function&&(e=i,i=null),this._showing>=0){if(!this.options.overlap)return void(this._nextRenderable?this._nextRenderable=t:(this._nextRenderable=t,this.hide(function(){this._nextRenderable===t&&this.show(this._nextRenderable,e),this._nextRenderable=null})));this.hide()}var s=null,a=this._renderables.indexOf(t);if(a>=0){this._showing=a,s=this._states[a],s.halt();var u=this._outgoingRenderables.indexOf(t);u>=0&&this._outgoingRenderables.splice(u,1)}else{s=new h(0);var c=new n({transform:this.inTransformMap?o.bind(this,this.inTransformMap,s):null,opacity:this.inOpacityMap?o.bind(this,this.inOpacityMap,s):null,origin:this.inOriginMap?o.bind(this,this.inOriginMap,s):null}),p=new r;p.add(c).add(t),this._showing=this._nodes.length,this._nodes.push(p),this._modifiers.push(c),this._states.push(s),this._renderables.push(t)}i||(i=this.options.inTransition),s.set(1,i,e)},s.prototype.hide=function(t,i){if(!(this._showing<0)){var e=this._showing;this._showing=-1,t instanceof Function&&(i=t,t=void 0);var s=this._nodes[e],n=this._modifiers[e],r=this._states[e],a=this._renderables[e];n.transformFrom(this.outTransformMap?o.bind(this,this.outTransformMap,r):null),n.opacityFrom(this.outOpacityMap?o.bind(this,this.outOpacityMap,r):null),n.originFrom(this.outOriginMap?o.bind(this,this.outOriginMap,r):null),this._outgoingRenderables.indexOf(a)<0&&this._outgoingRenderables.push(a),t||(t=this.options.outTransition),r.halt(),r.set(0,t,function(t,e,s,o){if(this._outgoingRenderables.indexOf(o)>=0){var n=this._nodes.indexOf(t);this._nodes.splice(n,1),this._modifiers.splice(n,1),this._states.splice(n,1),this._renderables.splice(n,1),this._outgoingRenderables.splice(this._outgoingRenderables.indexOf(o),1),this._showing>=n&&this._showing--}i&&i.call(this)}.bind(this,s,n,r,a))}},s.prototype.render=function(){var t=this._output;t.length>this._nodes.length&&t.splice(this._nodes.length);for(var i=0;i<this._nodes.length;i++)t[i]=this._nodes[i].render();return t},e.exports=s}),define("famous/views/EdgeSwapper",["require","exports","module","famous/transitions/CachedMap","famous/core/Entity","famous/core/EventHandler","famous/core/Transform","./RenderController"],function(t,i,e){function s(t){this._currentTarget=null,this._size=[void 0,void 0],this._controller=new u(t),this._controller.inTransformFrom(n.create(o.bind(this,1e-4))),this._controller.outTransformFrom(n.create(o.bind(this,-1e-4))),this._eventInput=new a,a.setInputHandler(this,this._eventInput),this._entityId=r.register(this),t&&this.setOptions(t)}function o(t,i){return h.translate(this._size[0]*(1-i),0,t*(1-i))}var n=t("famous/transitions/CachedMap"),r=t("famous/core/Entity"),a=t("famous/core/EventHandler"),h=t("famous/core/Transform"),u=t("./RenderController");s.prototype.show=function(t){this._currentTarget&&this._eventInput.unpipe(this._currentTarget),this._currentTarget=t,this._currentTarget&&this._currentTarget.trigger&&this._eventInput.pipe(this._currentTarget),this._controller.show.apply(this._controller,arguments)},s.prototype.setOptions=function(t){this._controller.setOptions(t)},s.prototype.render=function(){return this._entityId},s.prototype.commit=function(t){return this._size[0]=t.size[0],this._size[1]=t.size[1],{transform:t.transform,opacity:t.opacity,origin:t.origin,size:t.size,target:this._controller.render()}},e.exports=s}),define("famous/views/FlexibleLayout",["require","exports","module","famous/core/Entity","famous/core/Transform","famous/core/OptionsManager","famous/core/EventHandler","famous/transitions/Transitionable"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this.optionsManager=new a(this.options),t&&this.setOptions(t),this.id=n.register(this),this._ratios=new u(this.options.ratios),this._nodes=[],this._cachedDirection=null,this._cachedTotalLength=!1,this._cachedLengths=[],this._cachedTransforms=null,this._ratiosDirty=!1,this._eventOutput=new h,h.setOutputHandler(this,this._eventOutput)
|
|
}function o(t,i,e){var o,n,a,h,u=0,c=i,p=0;for(this._cachedLengths=[],this._cachedTransforms=[],h=0;h<t.length;h++)n=t[h],a=this._nodes[h],"number"!=typeof n?c-=a.getSize()[e]||0:p+=n;for(h=0;h<t.length;h++)a=this._nodes[h],n=t[h],i="number"==typeof n?c*n/p:a.getSize()[e],o=e===s.DIRECTION_X?r.translate(u,0,0):r.translate(0,u,0),this._cachedTransforms.push(o),this._cachedLengths.push(i),u+=i}var n=t("famous/core/Entity"),r=t("famous/core/Transform"),a=t("famous/core/OptionsManager"),h=t("famous/core/EventHandler"),u=t("famous/transitions/Transitionable");s.DIRECTION_X=0,s.DIRECTION_Y=1,s.DEFAULT_OPTIONS={direction:s.DIRECTION_X,transition:!1,ratios:[]},s.prototype.render=function(){return this.id},s.prototype.setOptions=function(t){this.optionsManager.setOptions(t)},s.prototype.sequenceFrom=function(t){if(this._nodes=t,0===this._ratios.get().length){for(var i=[],e=0;e<this._nodes.length;e++)i.push(1);this.setRatios(i)}},s.prototype.setRatios=function(t,i,e){void 0===i&&(i=this.options.transition);var s=this._ratios;0===s.get().length&&(i=void 0),s.isActive()&&s.halt(),s.set(t,i,e),this._ratiosDirty=!0},s.prototype.commit=function(t){var i,e=t.size,s=t.transform,n=t.origin,a=this._ratios.get(),h=this.options.direction,u=e[h];(u!==this._cachedTotalLength||this._ratiosDirty||this._ratios.isActive()||h!==this._cachedDirection)&&(o.call(this,a,u,h),u!==this._cachedTotalLength&&(this._cachedTotalLength=u),h!==this._cachedDirection&&(this._cachedDirection=h),this._ratiosDirty&&(this._ratiosDirty=!1));for(var c=[],p=0;p<a.length;p++)i=[void 0,void 0],u=this._cachedLengths[p],i[h]=u,c.push({transform:this._cachedTransforms[p],size:i,target:this._nodes[p].render()});return e&&0!==n[0]&&0!==n[1]&&(s=r.moveThen([-e[0]*n[0],-e[1]*n[1],0],s)),{transform:s,size:e,target:c}},e.exports=s}),define("famous/views/Flipper",["require","exports","module","famous/core/Transform","famous/transitions/Transitionable","famous/core/RenderNode","famous/core/OptionsManager"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this._optionsManager=new r(this.options),t&&this.setOptions(t),this.angle=new n(0),this.frontNode=void 0,this.backNode=void 0,this.flipped=!1}var o=t("famous/core/Transform"),n=t("famous/transitions/Transitionable"),r=(t("famous/core/RenderNode"),t("famous/core/OptionsManager"));s.DIRECTION_X=0,s.DIRECTION_Y=1;var a=1;s.DEFAULT_OPTIONS={transition:!0,direction:s.DIRECTION_X},s.prototype.flip=function(t,i){var e=this.flipped?0:Math.PI;this.setAngle(e,t,i),this.flipped=!this.flipped},s.prototype.setAngle=function(t,i,e){void 0===i&&(i=this.options.transition),this.angle.isActive()&&this.angle.halt(),this.angle.set(t,i,e)},s.prototype.setOptions=function(t){return this._optionsManager.setOptions(t)},s.prototype.setFront=function(t){this.frontNode=t},s.prototype.setBack=function(t){this.backNode=t},s.prototype.render=function(){var t,i,e=this.angle.get();this.options.direction===s.DIRECTION_X?(t=o.rotateY(e),i=o.rotateY(e+Math.PI)):(t=o.rotateX(e),i=o.rotateX(e+Math.PI));var n=[];return this.frontNode&&n.push({transform:t,target:this.frontNode.render()}),this.backNode&&n.push({transform:o.moveThen([0,0,a],i),target:this.backNode.render()}),n},e.exports=s}),define("famous/views/GridLayout",["require","exports","module","famous/core/Entity","famous/core/RenderNode","famous/core/Transform","famous/core/ViewSequence","famous/core/EventHandler","famous/core/Modifier","famous/core/OptionsManager","famous/transitions/Transitionable","famous/transitions/TransitionableTransform"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this.optionsManager=new l(this.options),t&&this.setOptions(t),this.id=a.register(this),this._modifiers=[],this._states=[],this._contextSizeCache=[0,0],this._dimensionsCache=[0,0],this._activeCount=0,this._eventOutput=new c,c.setOutputHandler(this,this._eventOutput)}function o(t,i,e){var s=[t[0],t[1]];s[0]-=this.options.gutterSize[0]*(i-1),s[1]-=this.options.gutterSize[1]*(e-1);for(var o,a=Math.round(s[1]/e),h=Math.round(s[0]/i),u=0,c=0,p=0;e>p;p++){o=0;for(var l=0;i>l;l++)void 0===this._modifiers[c]?n.call(this,c,[h,a],[o,u,0],1):r.call(this,c,[h,a],[o,u,0],1),c++,o+=h+this.options.gutterSize[0];u+=a+this.options.gutterSize[1]}for(this._dimensionsCache=[this.options.dimensions[0],this.options.dimensions[1]],this._contextSizeCache=[t[0],t[1]],this._activeCount=e*i,p=this._activeCount;p<this._modifiers.length;p++)r.call(this,p,[Math.round(h),Math.round(a)],[0,0],0);this._eventOutput.emit("reflow")}function n(t,i,e,s){var o={transform:new d(h.translate.apply(null,e)),opacity:new f(s),size:new f(i)},n=new p({transform:o.transform,opacity:o.opacity,size:o.size});this._states[t]=o,this._modifiers[t]=n}function r(t,i,e,s){var o=this._states[t],n=o.size,r=o.opacity,a=o.transform,h=this.options.transition;a.halt(),r.halt(),n.halt(),a.setTranslate(e,h),n.set(i,h),r.set(s,h)}var a=t("famous/core/Entity"),h=(t("famous/core/RenderNode"),t("famous/core/Transform")),u=t("famous/core/ViewSequence"),c=t("famous/core/EventHandler"),p=t("famous/core/Modifier"),l=t("famous/core/OptionsManager"),f=t("famous/transitions/Transitionable"),d=t("famous/transitions/TransitionableTransform");s.DEFAULT_OPTIONS={dimensions:[1,1],transition:!1,gutterSize:[0,0]},s.prototype.render=function(){return this.id},s.prototype.setOptions=function(t){return this.optionsManager.setOptions(t)},s.prototype.sequenceFrom=function(t){t instanceof Array&&(t=new u(t)),this.sequence=t},s.prototype.commit=function(t){var i=t.transform,e=t.opacity,s=t.origin,n=t.size,r=this.options.dimensions[0],a=this.options.dimensions[1];(n[0]!==this._contextSizeCache[0]||n[1]!==this._contextSizeCache[1]||r!==this._dimensionsCache[0]||a!==this._dimensionsCache[1])&&o.call(this,n,r,a);for(var u=this.sequence,c=[],p=0;u&&p<this._modifiers.length;){var l=u.get(),f=this._modifiers[p];p>=this._activeCount&&this._states[p].opacity.isActive()&&(this._modifiers.splice(p,1),this._states.splice(p,1)),l&&c.push(f.modify({origin:s,target:l.render()})),u=u.getNext(),p++}return n&&(i=h.moveThen([-n[0]*s[0],-n[1]*s[1],0],i)),{transform:i,opacity:e,size:n,target:c}},e.exports=s}),define("famous/views/HeaderFooterLayout",["require","exports","module","famous/core/Entity","famous/core/RenderNode","famous/core/Transform","famous/core/OptionsManager"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this._optionsManager=new c(this.options),t&&this.setOptions(t),this._entityId=a.register(this),this.header=new h,this.footer=new h,this.content=new h}function o(t,i){var e=t.getSize();return e?e[this.options.direction]:i}function n(t){return this.options.direction===s.DIRECTION_X?u.translate(t,0,0):u.translate(0,t,0)}function r(t,i){return this.options.direction===s.DIRECTION_X?[t,i[1]]:[i[0],t]}var a=t("famous/core/Entity"),h=t("famous/core/RenderNode"),u=t("famous/core/Transform"),c=t("famous/core/OptionsManager");s.DIRECTION_X=0,s.DIRECTION_Y=1,s.DEFAULT_OPTIONS={direction:s.DIRECTION_Y,headerSize:void 0,footerSize:void 0,defaultHeaderSize:0,defaultFooterSize:0},s.prototype.render=function(){return this._entityId},s.prototype.setOptions=function(t){return this._optionsManager.setOptions(t)},s.prototype.commit=function(t){var i=t.transform,e=t.origin,s=t.size,a=t.opacity,h=void 0!==this.options.headerSize?this.options.headerSize:o.call(this,this.header,this.options.defaultHeaderSize),c=void 0!==this.options.footerSize?this.options.footerSize:o.call(this,this.footer,this.options.defaultFooterSize),p=s[this.options.direction]-h-c;s&&(i=u.moveThen([-s[0]*e[0],-s[1]*e[1],0],i));var l=[{size:r.call(this,h,s),target:this.header.render()},{transform:n.call(this,h),size:r.call(this,p,s),target:this.content.render()},{transform:n.call(this,h+p),size:r.call(this,c,s),target:this.footer.render()}];return{transform:i,opacity:a,size:s,target:l}},e.exports=s}),define("famous/views/Lightbox",["require","exports","module","famous/core/Transform","famous/core/Modifier","famous/core/RenderNode","famous/utilities/Utility","famous/core/OptionsManager","famous/transitions/Transitionable","famous/transitions/TransitionableTransform"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this._optionsManager=new h(this.options),t&&this.setOptions(t),this._showing=!1,this.nodes=[],this.transforms=[],this.states=[]}var o=t("famous/core/Transform"),n=t("famous/core/Modifier"),r=t("famous/core/RenderNode"),a=t("famous/utilities/Utility"),h=t("famous/core/OptionsManager"),u=t("famous/transitions/Transitionable"),c=t("famous/transitions/TransitionableTransform");s.DEFAULT_OPTIONS={inTransform:o.scale(.001,.001,.001),inOpacity:0,inOrigin:[.5,.5],outTransform:o.scale(.001,.001,.001),outOpacity:0,outOrigin:[.5,.5],showTransform:o.identity,showOpacity:1,showOrigin:[.5,.5],inTransition:!0,outTransition:!0,overlap:!1},s.prototype.setOptions=function(t){return this._optionsManager.setOptions(t)},s.prototype.show=function(t,i,e){if(!t)return this.hide(e);if(i instanceof Function&&(e=i,i=void 0),this._showing){if(!this.options.overlap)return this.hide(this.show.bind(this,t,i,e));this.hide()}this._showing=!0;var s={transform:new c(this.options.inTransform),origin:new u(this.options.inOrigin),opacity:new u(this.options.inOpacity)},o=new n({transform:s.transform,opacity:s.opacity,origin:s.origin}),h=new r;h.add(o).add(t),this.nodes.push(h),this.states.push(s),this.transforms.push(o);var p=e?a.after(3,e):void 0;i||(i=this.options.inTransition),s.transform.set(this.options.showTransform,i,p),s.opacity.set(this.options.showOpacity,i,p),s.origin.set(this.options.showOrigin,i,p)},s.prototype.hide=function(t,i){if(this._showing){this._showing=!1,t instanceof Function&&(i=t,t=void 0);var e=this.nodes[this.nodes.length-1],s=this.transforms[this.transforms.length-1],o=this.states[this.states.length-1],n=a.after(3,function(){this.nodes.splice(this.nodes.indexOf(e),1),this.states.splice(this.states.indexOf(o),1),this.transforms.splice(this.transforms.indexOf(s),1),i&&i.call(this)}.bind(this));t||(t=this.options.outTransition),o.transform.set(this.options.outTransform,t,n),o.opacity.set(this.options.outOpacity,t,n),o.origin.set(this.options.outOrigin,t,n)}},s.prototype.render=function(){for(var t=[],i=0;i<this.nodes.length;i++)t.push(this.nodes[i].render());return t},e.exports=s}),define("famous/physics/forces/Drag",["require","exports","module","./Force"],function(t,i,e){function s(t){this.options=Object.create(this.constructor.DEFAULT_OPTIONS),t&&this.setOptions(t),o.call(this)}var o=t("./Force");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.FORCE_FUNCTIONS={LINEAR:function(t){return t},QUADRATIC:function(t){return t.mult(t.norm())}},s.DEFAULT_OPTIONS={strength:.01,forceFunction:s.FORCE_FUNCTIONS.LINEAR},s.prototype.applyForce=function(t){for(var i=this.options.strength,e=this.options.forceFunction,s=this.force,o=0;o<t.length;o++){var n=t[o];e(n.velocity).mult(-i).put(s),n.applyForce(s)}},s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},e.exports=s}),define("famous/views/Scroller",["require","exports","module","famous/core/Entity","famous/core/Group","famous/core/OptionsManager","famous/core/Transform","famous/utilities/Utility","famous/core/ViewSequence","famous/core/EventHandler"],function(t,i,e){function s(t){this.options=Object.create(this.constructor.DEFAULT_OPTIONS),this._optionsManager=new p(this.options),t&&this._optionsManager.setOptions(t),this._node=null,this._position=0,this._positionOffset=0,this._positionGetter=null,this._outputFunction=null,this._masterOutputFunction=null,this.outputFrom(),this._onEdge=0,this.group=new c,this.group.add({render:h.bind(this)}),this._entityId=u.register(this),this._size=[void 0,void 0],this._contextSize=[void 0,void 0],this._eventInput=new m,this._eventOutput=new m,m.setInputHandler(this,this._eventInput),m.setOutputHandler(this,this._eventOutput)}function o(t){t||(t=this._contextSize);var i=this.options.direction===f.Direction.X?0:1;return void 0===t[i]?this._contextSize[i]:t[i]}function n(t,i,e){var s=t.getSize?t.getSize():this._contextSize,n=this._outputFunction(i);return e.push({transform:n,target:t.render()}),o.call(this,s)}function r(){return this.options.clipSize?this.options.clipSize:o.call(this,this._contextSize)}function a(){for(var t=o.call(this,this._node.getSize()),i=this._node&&this._node.getNext?this._node.getNext():null;i&&this._position+this._positionOffset>=t;)this._positionOffset-=t,this._node=i,t=o.call(this,this._node.getSize()),i=this._node&&this._node.getNext?this._node.getNext():null;for(var e=this._node&&this._node.getPrevious?this._node.getPrevious():null;e&&this._position+this._positionOffset<0;){var s=o.call(this,e.getSize());this._positionOffset+=s,this._node=e,e=this._node&&this._node.getPrevious?this._node.getPrevious():null}}function h(){var t=null,i=this._position,e=[];this._onEdge=0;for(var s=-this._positionOffset,h=r.call(this),u=this._node;u&&s-i<h+this.options.margin;)s+=n.call(this,u,s,e),u=u.getNext?u.getNext():null;var c=this._node,p=o.call(this,c.getSize());if(h>s){for(;c&&h>p;)c=c.getPrevious(),c&&(p+=o.call(this,c.getSize()));for(c=this._node;c&&h>p;)c=c.getNext(),c&&(p+=o.call(this,c.getSize()))}var l=void 0!==p&&h>p?p:h;for(!u&&l>=s-i?(this._onEdge=1,this._eventOutput.emit("edgeHit",{position:s-l})):!this._node.getPrevious()&&0>=i&&(this._onEdge=-1,this._eventOutput.emit("edgeHit",{position:0})),u=this._node&&this._node.getPrevious?this._node.getPrevious():null,s=-this._positionOffset,u&&(t=u.getSize?u.getSize():this._contextSize,s-=o.call(this,t));u&&s-i>-(r.call(this)+this.options.margin);)n.call(this,u,s,e),u=u.getPrevious?u.getPrevious():null,u&&(t=u.getSize?u.getSize():this._contextSize,s-=o.call(this,t));return a.call(this),e}var u=t("famous/core/Entity"),c=t("famous/core/Group"),p=t("famous/core/OptionsManager"),l=t("famous/core/Transform"),f=t("famous/utilities/Utility"),d=t("famous/core/ViewSequence"),m=t("famous/core/EventHandler");s.DEFAULT_OPTIONS={direction:f.Direction.Y,margin:0,clipSize:void 0,groupScroll:!1},s.prototype.setOptions=function(t){this._optionsManager.setOptions(t),this.options.groupScroll?this.group.pipe(this._eventOutput):this.group.unpipe(this._eventOutput)},s.prototype.onEdge=function(){return this._onEdge},s.prototype.outputFrom=function(t,i){t||(t=function(t){return this.options.direction===f.Direction.X?l.translate(t,0):l.translate(0,t)}.bind(this),i||(i=t)),this._outputFunction=t,this._masterOutputFunction=i?i:function(i){return l.inverse(t(-i))}},s.prototype.positionFrom=function(t){t instanceof Function?this._positionGetter=t:t&&t.get?this._positionGetter=t.get.bind(t):(this._positionGetter=null,this._position=t),this._positionGetter&&(this._position=this._positionGetter.call(this))},s.prototype.sequenceFrom=function(t){t instanceof Array&&(t=new d({array:t})),this._node=t,this._positionOffset=0},s.prototype.getSize=function(t){return t?this._contextSize:this._size},s.prototype.render=function(){return this._node?(this._positionGetter&&(this._position=this._positionGetter.call(this)),this._entityId):null},s.prototype.commit=function(t){var i=t.transform,e=t.opacity,s=t.origin,o=t.size;this.options.clipSize||o[0]===this._contextSize[0]&&o[1]===this._contextSize[1]||(this._onEdge=0,this._contextSize[0]=o[0],this._contextSize[1]=o[1],this.options.direction===f.Direction.X?(this._size[0]=r.call(this),this._size[1]=void 0):(this._size[0]=void 0,this._size[1]=r.call(this)));var n=this._masterOutputFunction(-this._position);return{transform:l.multiply(i,n),size:o,opacity:e,origin:s,target:this.group.render()}},e.exports=s}),define("famous/views/Scrollview",["require","exports","module","famous/physics/PhysicsEngine","famous/physics/bodies/Particle","famous/physics/forces/Drag","famous/physics/forces/Spring","famous/core/EventHandler","famous/core/OptionsManager","famous/core/ViewSequence","famous/views/Scroller","famous/utilities/Utility","famous/inputs/GenericSync","famous/inputs/ScrollSync","famous/inputs/TouchSync"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this._optionsManager=new T(this.options),this._node=null,this._physicsEngine=new y,this._particle=new _,this._physicsEngine.addBody(this._particle),this.spring=new v({anchor:[0,0,0]}),this.drag=new g({forceFunction:g.FORCE_FUNCTIONS.QUADRATIC}),this.friction=new g({forceFunction:g.FORCE_FUNCTIONS.LINEAR}),this.sync=new x(["scroll","touch"],{direction:this.options.direction}),this._eventInput=new O,this._eventOutput=new O,this._eventInput.pipe(this.sync),this.sync.pipe(this._eventInput),O.setInputHandler(this,this._eventInput),O.setOutputHandler(this,this._eventOutput),this._touchCount=0,this._springState=0,this._onEdge=0,this._pageSpringPosition=0,this._edgeSpringPosition=0,this._touchVelocity=void 0,this._earlyEnd=!1,this._needsPaginationCheck=!1,this._scroller=new w,this._scroller.positionFrom(this.getPosition.bind(this)),this.setOptions(t),a.call(this)}function o(t){this._touchCount=t.count,void 0===t.count&&(this._touchCount=1),u.call(this),this.setVelocity(0),this._touchVelocity=0,this._earlyEnd=!1}function n(t){var i=-t.velocity,e=-t.delta;this._onEdge&&t.slip&&(0>i&&this._onEdge<0||i>0&&this._onEdge>0?this._earlyEnd||(r.call(this,t),this._earlyEnd=!0):this._earlyEnd&&Math.abs(i)>Math.abs(this.getVelocity())&&o.call(this,t)),this._earlyEnd||(this._touchVelocity=i,t.slip?this.setVelocity(i):this.setPosition(this.getPosition()+e))}function r(t){if(this._touchCount=t.count||0,!this._touchCount){u.call(this),this._onEdge&&f.call(this,this._edgeSpringPosition,C.EDGE),h.call(this);var i=-t.velocity,e=this.options.speedLimit;t.slip&&(e*=this.options.edgeGrip),-e>i?i=-e:i>e&&(i=e),this.setVelocity(i),this._touchVelocity=void 0,this._needsPaginationCheck=!0}}function a(){this._eventInput.bindThis(this),this._eventInput.on("start",o),this._eventInput.on("update",n),this._eventInput.on("end",r),this._scroller.on("edgeHit",function(t){this._edgeSpringPosition=t.position}.bind(this))}function h(){this._springState?this._physicsEngine.attach([this.spring],this._particle):this._physicsEngine.attach([this.drag,this.friction],this._particle)}function u(){this._springState=C.NONE,this._physicsEngine.detachAll()}function c(t){var i=this.options.direction,e=(t.getSize()||this._scroller.getSize())[i];return e||(e=this._scroller.getSize()[i]),e}function p(t){!this._onEdge&&t?(this.sync.setOptions({scale:this.options.edgeGrip}),this._touchCount||this._springState===C.EDGE||f.call(this,this._edgeSpringPosition,C.EDGE)):this._onEdge&&!t&&(this.sync.setOptions({scale:1}),this._springState&&Math.abs(this.getVelocity())<.001&&(u.call(this),h.call(this))),this._onEdge=t}function l(){if(this._needsPaginationCheck&&!this._touchCount&&this._springState!==C.EDGE){var t=this.getVelocity();if(!(Math.abs(t)>=this.options.pageStopSpeed)){var i=this.getPosition(),e=Math.abs(t)>this.options.pageSwitchSpeed,s=c.call(this,this._node),o=i>.5*s,n=t>0;o&&!e||e&&n?this.goToNextPage():f.call(this,0,C.PAGE),this._needsPaginationCheck=!1}}}function f(t,i){var e;i===C.EDGE?(this._edgeSpringPosition=t,e={anchor:[this._edgeSpringPosition,0,0],period:this.options.edgePeriod,dampingRatio:this.options.edgeDamp}):i===C.PAGE&&(this._pageSpringPosition=t,e={anchor:[this._pageSpringPosition,0,0],period:this.options.pagePeriod,dampingRatio:this.options.pageDamp}),this.spring.setOptions(e),i&&!this._springState&&(u.call(this),this._springState=i,h.call(this)),this._springState=i}function d(){for(var t=this.getPosition(),i=c.call(this,this._node),e=this._node.getNext();t>i+M&&e;)m.call(this,-i),t-=i,this._scroller.sequenceFrom(e),this._node=e,e=this._node.getNext(),i=c.call(this,this._node);for(var s,o=this._node.getPrevious();-M>t&&o;)s=c.call(this,o),this._scroller.sequenceFrom(o),this._node=o,m.call(this,s),t+=s,o=this._node.getPrevious()}function m(t){this._edgeSpringPosition+=t,this._pageSpringPosition+=t,this.setPosition(this.getPosition()+t),this._springState===C.EDGE?this.spring.setOptions({anchor:[this._edgeSpringPosition,0,0]}):this._springState===C.PAGE&&this.spring.setOptions({anchor:[this._pageSpringPosition,0,0]})}var y=t("famous/physics/PhysicsEngine"),_=t("famous/physics/bodies/Particle"),g=t("famous/physics/forces/Drag"),v=t("famous/physics/forces/Spring"),O=t("famous/core/EventHandler"),T=t("famous/core/OptionsManager"),S=t("famous/core/ViewSequence"),w=t("famous/views/Scroller"),b=t("famous/utilities/Utility"),x=t("famous/inputs/GenericSync"),E=t("famous/inputs/ScrollSync"),I=t("famous/inputs/TouchSync");x.register({scroll:E,touch:I});var M=.5;s.DEFAULT_OPTIONS={direction:b.Direction.Y,rails:!0,friction:.001,drag:1e-4,edgeGrip:.5,edgePeriod:300,edgeDamp:1,margin:1e3,paginated:!1,pagePeriod:500,pageDamp:.8,pageStopSpeed:10,pageSwitchSpeed:.5,speedLimit:10,groupScroll:!1};var C={NONE:0,EDGE:1,PAGE:2};s.prototype.outputFrom=function(){return this._scroller.outputFrom.apply(this._scroller,arguments)},s.prototype.getPosition=function(){return this._particle.getPosition1D()},s.prototype.setPosition=function(t){this._particle.setPosition1D(t)},s.prototype.getVelocity=function(){return this._touchCount?this._touchVelocity:this._particle.getVelocity1D()},s.prototype.setVelocity=function(t){this._particle.setVelocity1D(t)},s.prototype.setOptions=function(t){t&&(void 0!==t.direction&&("x"===t.direction?t.direction=b.Direction.X:"y"===t.direction&&(t.direction=b.Direction.Y)),this._scroller.setOptions(t),this._optionsManager.setOptions(t)),this._scroller.setOptions(this.options),this.options.groupScroll?this._scroller.pipe(this._eventInput):this._scroller.unpipe(this._eventInput),this.drag.setOptions({strength:this.options.drag}),this.friction.setOptions({strength:this.options.friction}),this.spring.setOptions({period:this.options.edgePeriod,dampingRatio:this.options.edgeDamp}),this.sync.setOptions({rails:this.options.rails,direction:this.options.direction===b.Direction.X?x.DIRECTION_X:x.DIRECTION_Y})},s.prototype.goToPreviousPage=function(){if(!this._node)return null;var t=this._node.getPrevious();if(t){var i=this.getPosition(),e=c.call(this,t);this._scroller.sequenceFrom(t),this._node=t;var s=M>i?-e:0;f.call(this,s,C.PAGE),m.call(this,e)}return this._eventOutput.emit("pageChange",{direction:-1}),t},s.prototype.goToNextPage=function(){if(!this._node)return null;var t=this._node.getNext();if(t){var i=this.getPosition(),e=c.call(this,this._node),s=c.call(this,t);this._scroller.sequenceFrom(t),this._node=t;var o=i>e-M?e+s:e;f.call(this,o,C.PAGE),m.call(this,-e)}return this._eventOutput.emit("pageChange",{direction:1}),t},s.prototype.sequenceFrom=function(t){return t instanceof Array&&(t=new S({array:t})),this._node=t,this._scroller.sequenceFrom(t)},s.prototype.getSize=function(){return this._scroller.getSize.apply(this._scroller,arguments)},s.prototype.render=function(){return this._node?(d.call(this),p.call(this,this._scroller.onEdge()),this.options.paginated&&l.call(this),this._scroller.render()):null},e.exports=s}),define("famous/views/ScrollContainer",["require","exports","module","famous/surfaces/ContainerSurface","famous/core/EventHandler","./Scrollview","famous/utilities/Utility","famous/core/OptionsManager"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this._optionsManager=new h(this.options),t&&this.setOptions(t),this.container=new o(this.options.container),this.scrollview=new r(this.options.scrollview),this.container.add(this.scrollview),n.setInputHandler(this,this.scrollview),n.setOutputHandler(this,this.scrollview),this.scrollview.subscribe(this.container)}var o=t("famous/surfaces/ContainerSurface"),n=t("famous/core/EventHandler"),r=t("./Scrollview"),a=t("famous/utilities/Utility"),h=t("famous/core/OptionsManager");s.DEFAULT_OPTIONS={container:{properties:{overflow:"hidden"}},scrollview:{direction:a.Direction.X}},s.prototype.setOptions=function(t){return this._optionsManager.setOptions(t)},s.prototype.sequenceFrom=function(){return this.scrollview.sequenceFrom.apply(this.scrollview,arguments)},s.prototype.render=function(){return this.container.render.apply(this.container,arguments)},e.exports=s}),define("famous/widgets/NavigationBar",["require","exports","module","famous/core/Scene","famous/core/Surface","famous/core/Transform","famous/core/View"],function(t,i,e){function s(){a.apply(this,arguments),this.title=new n({classes:this.options.classes,content:this.options.content}),this.back=new n({size:[this.options.size[1],this.options.size[1]],classes:this.options.classes,content:this.options.backContent}),this.back.on("click",function(){this._eventOutput.emit("back",{})}.bind(this)),this.more=new n({size:[this.options.size[1],this.options.size[1]],classes:this.options.classes,content:this.options.moreContent}),this.more.on("click",function(){this._eventOutput.emit("more",{})}.bind(this)),this.layout=new o({id:"master",size:this.options.size,target:[{transform:r.inFront,origin:[0,.5],target:this.back},{origin:[.5,.5],target:this.title},{transform:r.inFront,origin:[1,.5],target:this.more}]}),this._add(this.layout),this._optionsManager.on("change",function(t){var i=t.id,e=t.value;"size"===i?(this.layout.id.master.setSize(e),this.title.setSize(e),this.back.setSize([e[1],e[1]]),this.more.setSize([e[1],e[1]])):"backClasses"===i?this.back.setOptions({classes:this.options.classes.concat(this.options.backClasses)}):"backContent"===i?this.back.setContent(this.options.backContent):"classes"===i?(this.title.setOptions({classes:this.options.classes}),this.back.setOptions({classes:this.options.classes.concat(this.options.backClasses)}),this.more.setOptions({classes:this.options.classes.concat(this.options.moreClasses)})):"content"===i?this.setContent(this.options.content):"moreClasses"===i?this.more.setOptions({classes:this.options.classes.concat(this.options.moreClasses)}):"moreContent"===i&&this.more.setContent(this.options.content)}.bind(this))}var o=t("famous/core/Scene"),n=t("famous/core/Surface"),r=t("famous/core/Transform"),a=t("famous/core/View");s.prototype=Object.create(a.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={size:[void 0,50],backClasses:["back"],backContent:"◀",classes:["navigation"],content:"",moreClasses:["more"],moreContent:"✚"},s.prototype.setContent=function(t){return this.title.setContent(t)},e.exports=s}),define("famous/widgets/Slider",["require","exports","module","famous/core/Surface","famous/surfaces/CanvasSurface","famous/core/Transform","famous/core/EventHandler","famous/math/Utilities","famous/core/OptionsManager","famous/inputs/MouseSync","famous/inputs/TouchSync","famous/inputs/GenericSync"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),this.optionsManager=new c(this.options),t&&this.setOptions(t),this.indicator=new r({size:this.options.indicatorSize,classes:["slider-back"]}),this.label=new n({size:this.options.labelSize,content:this.options.label,properties:{pointerEvents:"none"},classes:["slider-label"]}),this.eventOutput=new h,this.eventInput=new h,h.setInputHandler(this,this.eventInput),h.setOutputHandler(this,this.eventOutput);var i=(this.options.range[1]-this.options.range[0])/this.options.indicatorSize[0];this.sync=new f(["mouse","touch"],{scale:i,direction:f.DIRECTION_X}),this.indicator.pipe(this.sync),this.sync.pipe(this),this.eventInput.on("update",function(t){this.set(t.position)}.bind(this)),this._drawPos=0,o.call(this)}function o(){this.label.setContent(this.options.label+'<span style="float: right">'+this.get().toFixed(this.options.precision)+"</span>")}var n=t("famous/core/Surface"),r=t("famous/surfaces/CanvasSurface"),a=t("famous/core/Transform"),h=t("famous/core/EventHandler"),u=t("famous/math/Utilities"),c=t("famous/core/OptionsManager"),p=t("famous/inputs/MouseSync"),l=t("famous/inputs/TouchSync"),f=t("famous/inputs/GenericSync");f.register({mouse:p,touch:l}),s.DEFAULT_OPTIONS={size:[200,60],indicatorSize:[200,30],labelSize:[200,30],range:[0,1],precision:2,value:0,label:"",fillColor:"rgba(170, 170, 170, 1)"},s.prototype.setOptions=function(t){return this.optionsManager.setOptions(t)},s.prototype.get=function(){return this.options.value},s.prototype.set=function(t){t!==this.options.value&&(this.options.value=u.clamp(t,this.options.range),o.call(this),this.eventOutput.emit("change",{value:t}))},s.prototype.getSize=function(){return this.options.size},s.prototype.render=function(){var t=this.options.range,i=Math.floor((this.get()-t[0])/(t[1]-t[0])*this.options.indicatorSize[0]);if(i<this._drawPos)this.indicator.getContext("2d").clearRect(i,0,this._drawPos-i+1,this.options.indicatorSize[1]);else if(i>this._drawPos){var e=this.indicator.getContext("2d");e.fillStyle=this.options.fillColor,e.fillRect(this._drawPos-1,0,i-this._drawPos+1,this.options.indicatorSize[1])}return this._drawPos=i,{size:this.options.size,target:[{origin:[0,0],target:this.indicator.render()},{transform:a.translate(0,0,1),origin:[0,0],target:this.label.render()}]}},e.exports=s}),define("famous/widgets/ToggleButton",["require","exports","module","famous/core/Surface","famous/core/EventHandler","famous/views/RenderController"],function(t,i,e){function s(t){this.options={content:"",offClasses:["off"],onClasses:["on"],size:void 0,outTransition:{curve:"easeInOut",duration:300},inTransition:{curve:"easeInOut",duration:300},toggleMode:s.TOGGLE,crossfade:!0},this._eventOutput=new n,n.setOutputHandler(this,this._eventOutput),this.offSurface=new o,this.offSurface.on("click",function(){this.options.toggleMode!==s.OFF&&this.select()}.bind(this)),this.offSurface.pipe(this._eventOutput),this.onSurface=new o,this.onSurface.on("click",function(){this.options.toggleMode!==s.ON&&this.deselect()}.bind(this)),this.onSurface.pipe(this._eventOutput),this.arbiter=new r({overlap:this.options.crossfade}),this.deselect(),t&&this.setOptions(t)}var o=t("famous/core/Surface"),n=t("famous/core/EventHandler"),r=t("famous/views/RenderController");s.OFF=0,s.ON=1,s.TOGGLE=2,s.prototype.select=function(){this.selected=!0,this.arbiter.show(this.onSurface,this.options.inTransition),this._eventOutput.emit("select")},s.prototype.deselect=function(){this.selected=!1,this.arbiter.show(this.offSurface,this.options.outTransition),this._eventOutput.emit("deselect")},s.prototype.isSelected=function(){return this.selected},s.prototype.setOptions=function(t){void 0!==t.content&&(this.options.content=t.content,this.offSurface.setContent(this.options.content),this.onSurface.setContent(this.options.content)),t.offClasses&&(this.options.offClasses=t.offClasses,this.offSurface.setClasses(this.options.offClasses)),t.onClasses&&(this.options.onClasses=t.onClasses,this.onSurface.setClasses(this.options.onClasses)),void 0!==t.size&&(this.options.size=t.size,this.onSurface.setSize(this.options.size),this.offSurface.setSize(this.options.size)),void 0!==t.toggleMode&&(this.options.toggleMode=t.toggleMode),void 0!==t.outTransition&&(this.options.outTransition=t.outTransition),void 0!==t.inTransition&&(this.options.inTransition=t.inTransition),void 0!==t.crossfade&&(this.options.crossfade=t.crossfade,this.arbiter.setOptions({overlap:this.options.crossfade}))},s.prototype.getSize=function(){return this.options.size},s.prototype.render=function(){return this.arbiter.render()},e.exports=s}),define("famous/widgets/TabBar",["require","exports","module","famous/utilities/Utility","famous/core/View","famous/views/GridLayout","./ToggleButton"],function(t,i,e){function s(){a.apply(this,arguments),this.layout=new h,this.buttons=[],this._buttonIds={},this._buttonCallbacks={},this.layout.sequenceFrom(this.buttons),this._add(this.layout),this._optionsManager.on("change",o.bind(this))}function o(t){var i=t.id,e=t.value;if("direction"===i)this.layout.setOptions({dimensions:n.call(this.buttons.length,this.options.direction)});else if("buttons"===i)for(var s in this.buttons)this.buttons[s].setOptions(e);else if("sections"===i)for(var o in this.options.sections)this.defineSection(o,this.options.sections[o])
|
|
}function n(t,i){return i===r.Direction.X?[t,1]:[1,t]}var r=t("famous/utilities/Utility"),a=t("famous/core/View"),h=t("famous/views/GridLayout"),u=t("./ToggleButton");s.prototype=Object.create(a.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={sections:[],widget:u,size:[void 0,50],direction:r.Direction.X,buttons:{toggleMode:u.ON}},s.prototype.defineSection=function(t,i){var e,s=this._buttonIds[t];if(void 0===s){s=this.buttons.length,this._buttonIds[t]=s;var o=this.options.widget;e=new o,this.buttons[s]=e,this.layout.setOptions({dimensions:n(this.buttons.length,this.options.direction)})}else e=this.buttons[s],e.unbind("select",this._buttonCallbacks[t]);this.options.buttons&&e.setOptions(this.options.buttons),e.setOptions(i),this._buttonCallbacks[t]=this.select.bind(this,t),e.on("select",this._buttonCallbacks[t])},s.prototype.select=function(t){var i=this._buttonIds[t];this.buttons[i]&&this.buttons[i].isSelected()?this._eventOutput.emit("select",{id:t}):this.buttons[i]&&this.buttons[i].select();for(var e=0;e<this.buttons.length;e++)e!==i&&this.buttons[e].deselect()},e.exports=s}),define("famous/physics/forces/Repulsion",["require","exports","module","./Force","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this.disp=new n,o.call(this)}var o=t("./Force"),n=t("famous/math/Vector");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DECAY_FUNCTIONS={LINEAR:function(t,i){return Math.max(1-1/i*t,0)},MORSE:function(t,i){var e=0===i?100:i,s=t+e*(1-Math.log(2));return Math.max(1-Math.pow(1-Math.exp(s/e-1),2),0)},INVERSE:function(t,i){return 1/(1-i+t)},GRAVITY:function(t,i){return 1/(1-i+t*t)}},s.DEFAULT_OPTIONS={strength:1,anchor:void 0,range:[0,1/0],cutoff:0,cap:1/0,decayFunction:s.DECAY_FUNCTIONS.GRAVITY},s.prototype.setOptions=function(t){void 0!==t.anchor&&(t.anchor.position instanceof n&&(this.options.anchor=t.anchor.position),t.anchor instanceof Array&&(this.options.anchor=new n(t.anchor)),delete t.anchor);for(var i in t)this.options[i]=t[i]},s.prototype.applyForce=function(t,i){var e=this.options,s=this.force,o=this.disp,n=e.strength,r=e.anchor||i.position,a=e.cap,h=e.cutoff,u=e.range[0],c=e.range[1],p=e.decayFunction;if(0!==n)for(var l in t){var f=t[l];if(f!==i){var d=f.mass,m=f.position;o.set(m.sub(r));var y=o.norm();c>y&&y>u&&(s.set(o.normalize(n*d*p(y,h)).cap(a)),f.applyForce(s))}}},e.exports=s}),define("famous/physics/forces/RotationalDrag",["require","exports","module","./Drag"],function(t,i,e){function s(t){o.call(this,t)}var o=t("./Drag");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS=o.DEFAULT_OPTIONS,s.FORCE_FUNCTIONS=o.FORCE_FUNCTIONS,s.FORCE_FUNCTIONS={LINEAR:function(t){return t},QUADRATIC:function(t){return t.mult(t.norm())}},s.prototype.applyForce=function(t){for(var i=this.options.strength,e=this.options.forceFunction,s=this.force,o=0;o<t.length;o++){var n=t[o];e(n.angularVelocity).mult(-100*i).put(s),n.applyTorque(s)}},s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},e.exports=s}),define("famous/physics/forces/RotationalSpring",["require","exports","module","./Spring"],function(t,i,e){function s(t){o.call(this,t)}var o=t("./Spring");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS=o.DEFAULT_OPTIONS,s.FORCE_FUNCTIONS=o.FORCE_FUNCTIONS,s.prototype.applyForce=function(t){for(var i=this.force,e=this.options,s=this.disp,o=e.stiffness,n=e.damping,r=e.length,a=e.anchor,h=0;h<t.length;h++){var u=t[h];s.set(a.sub(u.orientation));var c=s.norm()-r;if(0===c)return;var p=u.mass;o*=p,n*=p,i.set(s.normalize(o*this.forceFunction(c,this.options.lMax))),n&&i.set(i.add(u.angularVelocity.mult(-n))),u.applyTorque(i)}},s.prototype.getEnergy=function(t){var i=this.options,e=i.length,s=i.anchor,o=i.stiffness,n=s.sub(t.orientation).norm()-e;return.5*o*n*n},e.exports=s}),define("famous/physics/forces/VectorField",["require","exports","module","./Force","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),o.call(this,this.options.field),r.call(this),this.evaluation=new a(0,0,0)}function o(t){var i=s.FIELDS;switch(t){case i.CONSTANT:this.options.direction||(this.options.direction=new a(0,1,0));break;case i.POINT_ATTRACTOR:this.options.position||(this.options.position=new a(0,0,0));break;case i.SPHERE_ATTRACTOR:this.options.radius||(this.options.radius=1)}}function n(t){var i=this.evaluation,e=this.options.field;return i.set(t),e(i,this.options)}var r=t("./Force"),a=t("famous/math/Vector");s.prototype=Object.create(r.prototype),s.prototype.constructor=s,s.FIELDS={CONSTANT:function(t,i){return t.set(i.direction)},LINEAR:function(t){return t},RADIAL:function(t){return t.set(t.mult(-1,t))},SPHERE_ATTRACTOR:function(t,i){return t.set(t.mult((i.radius-t.norm())/t.norm()))},POINT_ATTRACTOR:function(t,i){return t.set(i.position.sub(t))}},s.DEFAULT_OPTIONS={strength:1,field:s.FIELDS.CONSTANT},s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},s.prototype.applyForce=function(t){for(var i=this.force,e=0;e<t.length;e++){var s=t[e];i.set(n.call(this,s.position).mult(s.mass*this.options.strength)),s.applyForce(i)}},e.exports=s}),define("famous/physics/bodies/Body",["require","exports","module","./Particle","famous/core/Transform","famous/math/Vector","famous/math/Quaternion","famous/math/Matrix"],function(t,i,e){function s(t){o.call(this,t),t=t||{},this.orientation=new a,this.angularVelocity=new r,this.angularMomentum=new r,this.torque=new r,t.orientation&&this.orientation.set(t.orientation),t.angularVelocity&&this.angularVelocity.set(t.angularVelocity),t.angularMomentum&&this.angularMomentum.set(t.angularMomentum),t.torque&&this.torque.set(t.torque),this.setMomentsOfInertia(),this.angularVelocity.w=0,this.pWorld=new r}var o=t("./Particle"),n=t("famous/core/Transform"),r=t("famous/math/Vector"),a=t("famous/math/Quaternion"),h=t("famous/math/Matrix");s.DEFAULT_OPTIONS=o.DEFAULT_OPTIONS,s.DEFAULT_OPTIONS.orientation=[0,0,0,1],s.DEFAULT_OPTIONS.angularVelocity=[0,0,0],s.AXES=o.AXES,s.SLEEP_TOLERANCE=o.SLEEP_TOLERANCE,s.INTEGRATOR=o.INTEGRATOR,s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.isBody=!0,s.prototype.setMass=function(){o.prototype.setMass.apply(this,arguments),this.setMomentsOfInertia()},s.prototype.setMomentsOfInertia=function(){this.inertia=new h,this.inverseInertia=new h},s.prototype.updateAngularVelocity=function(){this.angularVelocity.set(this.inverseInertia.vectorMultiply(this.angularMomentum))},s.prototype.toWorldCoordinates=function(t){return this.pWorld.set(this.orientation.rotateVector(t))},s.prototype.getEnergy=function(){return o.prototype.getEnergy.call(this)+.5*this.inertia.vectorMultiply(this.angularVelocity).dot(this.angularVelocity)},s.prototype.reset=function(t,i,e,s){o.prototype.reset.call(this,t,i),this.angularVelocity.clear(),this.setOrientation(e||[1,0,0,0]),this.setAngularMomentum(s||[0,0,0])},s.prototype.setOrientation=function(t){this.orientation.set(t)},s.prototype.setAngularVelocity=function(t){this.wake(),this.angularVelocity.set(t)},s.prototype.setAngularMomentum=function(t){this.wake(),this.angularMomentum.set(t)},s.prototype.applyForce=function(t,i){o.prototype.applyForce.call(this,t),void 0!==i&&this.applyTorque(i.cross(t))},s.prototype.applyTorque=function(t){this.wake(),this.torque.set(this.torque.add(t))},s.prototype.getTransform=function(){return n.thenMove(this.orientation.getTransform(),n.getTranslate(o.prototype.getTransform.call(this)))},s.prototype._integrate=function(t){o.prototype._integrate.call(this,t),this.integrateAngularMomentum(t),this.updateAngularVelocity(t),this.integrateOrientation(t)},s.prototype.integrateAngularMomentum=function(t){s.INTEGRATOR.integrateAngularMomentum(this,t)},s.prototype.integrateOrientation=function(t){s.INTEGRATOR.integrateOrientation(this,t)},e.exports=s}),define("famous/physics/bodies/Circle",["require","exports","module","./Body","famous/math/Matrix"],function(t,i,e){function s(t){t=t||{},this.setRadius(t.radius||0),o.call(this,t)}var o=t("./Body"),n=t("famous/math/Matrix");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.setRadius=function(t){this.radius=t,this.size=[2*this.radius,2*this.radius],this.setMomentsOfInertia()},s.prototype.setMomentsOfInertia=function(){var t=this.mass,i=this.radius;this.inertia=new n([[.25*t*i*i,0,0],[0,.25*t*i*i,0],[0,0,.5*t*i*i]]),this.inverseInertia=new n([[4/(t*i*i),0,0],[0,4/(t*i*i),0],[0,0,2/(t*i*i)]])},e.exports=s}),define("famous/physics/bodies/Rectangle",["require","exports","module","./Body","famous/math/Matrix"],function(t,i,e){function s(t){t=t||{},this.size=t.size||[0,0],o.call(this,t)}var o=t("./Body"),n=t("famous/math/Matrix");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.setSize=function(t){this.size=t,this.setMomentsOfInertia()},s.prototype.setMomentsOfInertia=function(){var t=this.mass,i=this.size[0],e=this.size[1];this.inertia=new n([[t*e*e/12,0,0],[0,t*i*i/12,0],[0,0,t*(i*i+e*e)/12]]),this.inverseInertia=new n([[12/(t*e*e),0,0],[0,12/(t*i*i),0],[0,0,12/(t*(i*i+e*e))]])},e.exports=s}),define("famous/physics/constraints/Collision",["require","exports","module","./Constraint","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this.normal=new n,this.pDiff=new n,this.vDiff=new n,this.impulse1=new n,this.impulse2=new n,o.call(this)}var o=t("./Constraint"),n=t("famous/math/Vector");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={restitution:.5,drift:.5,slop:0},s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},s.prototype.applyConstraint=function(t,i,e){if(void 0!==i)for(var s=i.velocity,o=i.position,n=i.inverseMass,r=i.radius,a=this.options,h=a.drift,u=-a.slop,c=a.restitution,p=this.normal,l=this.pDiff,f=this.vDiff,d=this.impulse1,m=this.impulse2,y=0;y<t.length;y++){var _=t[y];if(_!==i){var g=_.velocity,v=_.position,O=_.inverseMass,T=_.radius;l.set(v.sub(o)),f.set(g.sub(s));var S=l.norm(),w=S-(r+T),b=1/(n+O),x=0;if(0>w){if(p.set(l.normalize()),this._eventOutput){var E={target:_,source:i,overlap:w,normal:p};this._eventOutput.emit("preCollision",E),this._eventOutput.emit("collision",E)}var I=u>=w?((1+c)*p.dot(f)+h/e*(w-u))/(x+e/b):(1+c)*p.dot(f)/(x+e/b);p.mult(e*I).put(d),d.mult(-1).put(m),i.applyImpulse(d),_.applyImpulse(m),this._eventOutput&&this._eventOutput.emit("postCollision",E)}}}},e.exports=s}),define("famous/physics/constraints/Curve",["require","exports","module","./Constraint","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this.J=new n,this.impulse=new n,o.call(this)}var o=t("./Constraint"),n=t("famous/math/Vector");s.prototype=Object.create(o.prototype),s.prototype.constructor=s;var r=1e-7,a=Math.PI;s.DEFAULT_OPTIONS={equation:function(){return 0},plane:function(t,i,e){return e},period:0,dampingRatio:0},s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},s.prototype.applyConstraint=function(t,i,e){for(var s=this.options,o=this.impulse,n=this.J,h=s.equation,u=s.plane,c=s.dampingRatio,p=s.period,l=0;l<t.length;l++){var f,d,m=t[l],y=m.velocity,_=m.position,g=m.mass;if(0===p)f=0,d=1;else{var v=4*g*a*c/p,O=4*g*a*a/(p*p);f=1/(v+e*O),d=e*O/(v+e*O)}var T=_.x,S=_.y,w=_.z,b=h(T,S,w),x=(h(T+r,_,_)-b)/r,E=(h(T,S+r,_)-b)/r,I=(h(T,S,_+r)-b)/r,M=u(T,S,w),C=(u(T+r,S,w)-M)/r,z=(u(T,S+r,w)-M)/r,P=(u(T,S,w+r)-M)/r;n.setXYZ(x+C,E+z,I+P);var F=d/e*(b+M),N=-(n.dot(y)+F)/(f+e*n.normSquared()/g);o.set(n.mult(e*N)),m.applyImpulse(o)}},e.exports=s}),define("famous/physics/constraints/Distance",["require","exports","module","./Constraint","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(this.constructor.DEFAULT_OPTIONS),t&&this.setOptions(t),this.impulse=new n,this.normal=new n,this.diffP=new n,this.diffV=new n,o.call(this)}var o=t("./Constraint"),n=t("famous/math/Vector");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={anchor:null,length:0,minLength:0,period:0,dampingRatio:0};var r=Math.PI;s.prototype.setOptions=function(t){t.anchor&&(t.anchor.position instanceof n&&(this.options.anchor=t.anchor.position),t.anchor instanceof n&&(this.options.anchor=t.anchor),t.anchor instanceof Array&&(this.options.anchor=new n(t.anchor))),void 0!==t.length&&(this.options.length=t.length),void 0!==t.dampingRatio&&(this.options.dampingRatio=t.dampingRatio),void 0!==t.period&&(this.options.period=t.period),void 0!==t.minLength&&(this.options.minLength=t.minLength)},s.prototype.setAnchor=function(t){this.options.anchor||(this.options.anchor=new n),this.options.anchor.set(t)},s.prototype.applyConstraint=function(t,i,e){var s,o,n=this.normal,a=this.diffP,h=this.diffV,u=this.impulse,c=this.options,p=c.dampingRatio,l=c.period,f=c.minLength;if(i){var d=i.velocity;s=i.position,o=i.inverseMass}else s=this.options.anchor,o=0;for(var m=this.options.length,y=0;y<t.length;y++){var _=t[y],g=_.velocity,v=_.position,O=_.inverseMass;a.set(v.sub(s)),n.set(a.normalize());var T=a.norm()-m;if(Math.abs(T)<f)return;h.set(i?g.sub(d):g);var S,w,b=1/(O+o);if(0===l)S=0,w=1;else{var x=4*b*r*p/l,E=4*b*r*r/(l*l);S=1/(x+e*E),w=e*E/(x+e*E)}var I=w/e*T,M=-(n.dot(h)+I)/(S+e/b);u.set(n.mult(e*M)),_.applyImpulse(u),i&&i.applyImpulse(u.mult(-1))}},e.exports=s}),define("famous/physics/constraints/Surface",["require","exports","module","./Constraint","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),this.J=new n,this.impulse=new n,o.call(this)}var o=t("./Constraint"),n=t("famous/math/Vector");s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.DEFAULT_OPTIONS={equation:void 0,period:0,dampingRatio:0};var r=1e-7,a=Math.PI;s.prototype.setOptions=function(t){for(var i in t)this.options[i]=t[i]},s.prototype.applyConstraint=function(t,i,e){for(var s=this.impulse,o=this.J,n=this.options,h=n.equation,u=n.dampingRatio,c=n.period,p=0;p<t.length;p++){var l,f,d=t[p],m=d.velocity,y=d.position,_=d.mass;if(0===c)l=0,f=1;else{var g=4*_*a*u/c,v=4*_*a*a/(c*c);l=1/(g+e*v),f=e*v/(g+e*v)}var O=y.x,T=y.y,S=y.z,w=h(O,T,S),b=(h(O+r,y,y)-w)/r,x=(h(O,T+r,y)-w)/r,E=(h(O,T,y+r)-w)/r;o.setXYZ(b,x,E);var I=f/e*w,M=-(o.dot(m)+I)/(l+e*o.normSquared()/_);s.set(o.mult(e*M)),d.applyImpulse(s)}},e.exports=s}),define("famous/physics/constraints/Walls",["require","exports","module","./Constraint","./Wall","famous/math/Vector"],function(t,i,e){function s(t){this.options=Object.create(s.DEFAULT_OPTIONS),t&&this.setOptions(t),n.call(this,t.sides||this.options.sides),a.call(this)}function o(t,i,e){var o,n=s.SIDES;switch(parseInt(t)){case n.LEFT:o=i[0]*e[0];break;case n.TOP:o=i[1]*e[1];break;case n.FRONT:o=i[2]*e[2];break;case n.RIGHT:o=i[0]*(1-e[0]);break;case n.BOTTOM:o=i[1]*(1-e[1]);break;case n.BACK:o=i[2]*(1-e[2])}return o}function n(t){this.components={};for(var i=this.components,e=0;e<t.length;e++){var s=t[e];i[e]=new h({normal:c[s].clone(),distance:o(s,this.options.size,this.options.origin)})}}function r(t){this.forEach(function(i){i.setOptions(t)});for(var i in t)this.options[i]=t[i]}var a=t("./Constraint"),h=t("./Wall"),u=t("famous/math/Vector");s.prototype=Object.create(a.prototype),s.prototype.constructor=s,s.ON_CONTACT=h.ON_CONTACT,s.SIDES={LEFT:0,RIGHT:1,TOP:2,BOTTOM:3,FRONT:4,BACK:5,TWO_DIMENSIONAL:[0,1,2,3],THREE_DIMENSIONAL:[0,1,2,3,4,5]},s.DEFAULT_OPTIONS={sides:s.SIDES.TWO_DIMENSIONAL,size:[window.innerWidth,window.innerHeight,0],origin:[.5,.5,.5],drift:.5,slop:0,restitution:.5,onContact:s.ON_CONTACT.REFLECT};var c={0:new u(1,0,0),1:new u(-1,0,0),2:new u(0,1,0),3:new u(0,-1,0),4:new u(0,0,1),5:new u(0,0,-1)};s.prototype.setOptions=function(t){var i=!1;void 0!==t.restitution&&r.call(this,{restitution:t.restitution}),void 0!==t.drift&&r.call(this,{drift:t.drift}),void 0!==t.slop&&r.call(this,{slop:t.slop}),void 0!==t.onContact&&r.call(this,{onContact:t.onContact}),void 0!==t.size&&(i=!0),void 0!==t.sides&&(this.options.sides=t.sides),void 0!==t.origin&&(i=!0),i&&this.setSize(t.size,t.origin)},s.prototype.setSize=function(t,i){i=i||this.options.origin,i.length<3&&(i[2]=.5),this.forEach(function(e,s){var n=o(s,t,i);e.setOptions({distance:n})}),this.options.size=t,this.options.origin=i},s.prototype.applyConstraint=function(t,i,e){this.forEach(function(s){s.applyConstraint(t,i,e)})},s.prototype.forEach=function(t){for(var i in this.sides)t(this.sides[i],i)},s.prototype.rotateZ=function(t){this.forEach(function(i){var e=i.options.normal;e.rotateZ(t).put(e)})},s.prototype.rotateX=function(t){this.forEach(function(i){var e=i.options.normal;e.rotateX(t).put(e)})},s.prototype.rotateY=function(t){this.forEach(function(i){var e=i.options.normal;e.rotateY(t).put(e)})},e.exports=s}); |