50 lines
175 KiB
JavaScript
50 lines
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
|
||
|
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 t
|
||
|
},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.ch
|
||
|
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 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
|
||
|
}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)
|