react-spring
Advanced tools
Comparing version 3.2.0-beta.11 to 3.2.0-beta.12
@@ -1,1 +0,1 @@ | ||
import normalizeColor from"normalize-css-color";import React from"react";import PropTypes from"prop-types";function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),_class=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(_class),_class$1=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}();function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var _class$2=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){0===this._animatedStyles.size&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){this._value=t,this._flush()},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(_class),_class$3=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new _class$2(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(_class),_class$4=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(_class),_class$5=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this).onUpdate=function(){var t=Date.now();t>n._lastTime+64&&(t=n._lastTime+64);var e=(t-n._lastTime)/1e3;n._frameTime+=e;var i=n._friction,r=n._mass,a=n._tension,o=-n._initialVelocity,s=i/(2*Math.sqrt(a*r)),l=Math.sqrt(a/r),c=l*Math.sqrt(1-s*s),u=n._toValue-n._startPosition,p=0,f=0,h=n._frameTime;if(s<1){var d=Math.exp(-s*l*h);p=n._toValue-d*((o+s*l*u)/c*Math.sin(c*h)+u*Math.cos(c*h)),f=s*l*d*(Math.sin(c*h)*(o+s*l*u)/c+u*Math.cos(c*h))-d*(Math.cos(c*h)*(o+s*l*u)-c*u*Math.sin(c*h))}else{var _=Math.exp(-l*h);p=n._toValue-_*(u+(o+l*u)*h),f=_*(o*(h*l-1)+h*u*(l*l))}if(n._lastTime=t,n._lastPosition=p,n._lastVelocity=f,n._onUpdate(p),n.__active){var m=!1;n._overshootClamping&&0!==n._stiffness&&(m=n._startPosition<n._toValue?p>n._toValue:p<n._toValue);var v=Math.abs(f)<=n._restSpeedThreshold,g=!0;if(0!==n._stiffness&&(g=Math.abs(n._toValue-p)<=n._restDisplacementThreshold),m||v&&g)return 0!==n._stiffness&&(n._lastPosition=n._toValue,n._lastVelocity=0,n._onUpdate(n._toValue)),n.__debouncedOnEnd({finished:!0});n._animationFrame=RequestAnimationFrame.current(n.onUpdate)}},n._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,1e-4),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,1e-4),n._initialVelocity=withDefault(e.velocity,0),n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n._mass=withDefault(e.mass,1),n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),this._frameTime=0,r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(_class$1),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},_class$6=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(_class),_class$7=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new _class$6(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new _class$7(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof _class$3?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new _class$5(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:_class$2,Array:_class$3,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new _class$4(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:_class$7},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return n=t.call(this)||this,_initialiseProps.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n.update=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset;t.onUpdate;void 0===e&&(e=!1);var c=Object.entries(_extends({},i,r)),u=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(t,r,c){var p,f=r[0],h=r[1],d=!1===l&&n.animations[f]||(n.animations[f]={}),_="number"==typeof h,m=!_&&Array.isArray(h),v=void 0!==i[f]?i[f]:h,g=_||m?h:1;if(_&&o){var y=o(n),A=y&&y.animations[f];A&&(g=A.animation)}if(_)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(m)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(u);d.animation=n.defaultAnimation,d.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,h]})}return!s||!0!==s&&-1===s.indexOf(f)||d.animation.setValue(g),d.start=function(){return exports$2.spring(d.animation,_extends({toValue:g},a)).start(0===c&&n.onRest)},d.stop=function(){return d.animation.stopAnimation()},e&&d.start(),n.interpolators[f]=d.interpolation,_extends({},t,((p={})[f]=d,p))},{});var p=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),p&&p.__detach()},n.componentWillReceiveProps=function(t){this.update(t,!0)},n.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},n.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},a,r,{children:e})):e(_extends({},a,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1};var _initialiseProps=function(){var t=this;this.callback=function(){t.props.onUpdate&&t.props.onUpdate(t.propsAnimated.__getValue()),!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},callOrRefer=function(t,e){return"function"==typeof t?t(e):t},Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.from,s=e.enter,l=(e.leave,e.update);e.accessor;return i=r||i,Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionsKeys:a,transitions:i.map(function(t,e){return{children:t,key:a[e],to:callOrRefer(s,a[e]),from:callOrRefer(o,a[e]),update:callOrRefer(l,a[e])}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionsKeys,a=t.children,o=t.render,s=t.keys,l=t.from,c=t.enter,u=t.leave,p=t.update,f=t.accessor;a=o||a,Array.isArray(a)||(a=[a],s=s?[s]:a);var h=s.map(function(t){return f(t)}),d=r.map(function(t){return f(t)}),_=new Set(h),m=new Set(d),v=h.filter(function(t){return!m.has(t)}),g=d.filter(function(t){return!_.has(t)}),y=h.filter(function(t){return m.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=h.indexOf(f(t.key)),n=a[e];n&&(t.children=n),p&&-1!==y.indexOf(f(t.key))&&(t.to=callOrRefer(p,s[e])||t.to)}return t}),v.length&&v.forEach(function(t){var e=h.indexOf(t),n={children:a[e],key:s[e],to:callOrRefer(c,s[e]),from:callOrRefer(l,s[e])};i=i.slice(0,e).concat([n],i.slice(e))}),g.length&&g.forEach(function(t){var n=i.find(function(e){return f(e.key)===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:callOrRefer(u,n.key),from:callOrRefer(l,n.key),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var A=s.map(function(t){return i.find(function(e){return f(e.key)===f(t)})});g.forEach(function(t){var e=i.findIndex(function(e){return f(e.key)===t}),n=i.find(function(e){return f(e.key)===t});n&&(A=A.slice(0,e).concat([n],A.slice(e)))}),this.setState({transitions:A,transitionsKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.accessor),o=e.onUpdate,s=_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","accessor","onUpdate"]));return this.state.transitions.map(function(e){var i=e.key,r=e.children,l=_objectWithoutProperties(e,["key","children"]);return React.createElement(Spring,_extends({key:a(i)},l,s,{onUpdate:o&&function(t){return o(i,t)},render:n&&r,children:n?t.props.children:r}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default,accessor:function(t){return t}};var _class$8,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,r=t.to,a=t.native,o=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),c=new Set,u=_extends({},l,{native:a,config:o,from:i,to:r});return(n||e).map(function(t,i){return React.createElement(Spring,_extends({key:s[i]},u,{attach:function(t){return function(t,e){return c.add(e),0===t?void 0:Array.from(c)[t-1]}(i,t)},render:n&&t,children:n?e:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps$1.call(_assertThisInitialized(n)),n.state={ready:!1},n.layers=[],n.space=0,n.current=0,n.offset=0,n.busy=!1,n}_inheritsLoose(e,t);var n=e.prototype;return n.scrollTo=function(t){var e=this.props,n=e.horizontal,i=e.config;this.scrollStop(),this.offset=t;var r=this.refs.container;this.animatedScroll=new exports$2.Value(r[n?"scrollLeft":"scrollTop"]),this.animatedScroll.addListener(function(t){var e=t.value;return r[n?"scrollLeft":"scrollTop"]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,c=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:c,overflowY:l?"hidden":c,overflowX:l?c:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class$8=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class$8.contextTypes={parallax:PropTypes.object},_class$8.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps$1=function(){var t=this;this.moveItems=function(){t.layers.forEach(function(e){return e.setPosition(t.space,t.current)}),t.busy=!1},this.scrollerRaf=function(){return requestAnimationFrame(t.moveItems)},this.onScroll=function(e){var n=t.props.horizontal;t.busy||(t.busy=!0,t.scrollerRaf(),t.current=e.target[n?"scrollLeft":"scrollTop"])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal;t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[i?"scrollLeft":"scrollTop"]:t.refs.container[i?"scrollLeft":"scrollTop"]=t.current=t.offset*t.space,t.refs.content&&(t.refs.content.style[i?"width":"height"]=t.space*t.props.pages+"px"),t.layers.forEach(function(e){e.setHeight(t.space,!0),e.setPosition(t.space,t.current,!0)}))},this.updateRaf=function(){requestAnimationFrame(t.update),setTimeout(t.update,150)},this.scrollStop=function(e){return t.animatedScroll&&t.animatedScroll.stopAnimation()}};export{Spring,Transition,Trail,Parallax,config,template,animated,interpolate$1 as interpolate}; | ||
import normalizeColor from"normalize-css-color";import React from"react";import PropTypes from"prop-types";function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o._hey=1,o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){t instanceof AnimatedTracking&&(this._tracked=!0),0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(AnimatedWithChildren),Animation=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}(),_uniqueId=0;function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){(0===this._animatedStyles.size||this._tracked)&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){for(var e in this._value=t,this._flush(),this._listeners)this._listeners[e]({value:this.__getValue()})},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.addListener=function(t){var e=String(_uniqueId++);return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new AnimatedValue(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var a=Math.floor((r-this._lastTime)/1),o=0;o<a;++o){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,u=(n=t+.001*s/2,i=e+.001*l/2),c=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*u/2;var h=i=e+.001*c/2,p=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*h/2;var f=i=e+.001*p/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*h/2,i=e+.001*p/2,t+=.001*((s+2*(u+h)+f)/6),e+=.001*((l+2*(c+p)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var m=!1;this._overshootClamping&&0!==this._tension&&(m=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var _=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),m||_&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof AnimatedArray?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return n=t.call(this)||this,_initialiseProps.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n.update=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset;t.onFrame;void 0===e&&(e=!1);var u=Object.entries(_extends({},i,r)),c=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=u.reduce(function(t,r,u){var h,p=r[0],f=r[1],d=!1===l&&n.animations[p]||(n.animations[p]={}),m="number"==typeof f,_=!m&&Array.isArray(f),v=void 0!==i[p]?i[p]:f,g=m||_?f:1;if(m&&o){var y=o(n),A=y&&y.animations[p];A&&(g=A.animation)}if(m)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(_)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(c);d.animation=n.defaultAnimation,d.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,f]})}return!s||!0!==s&&-1===s.indexOf(p)||d.animation.setValue(g),d.start=function(){return exports$2.spring(d.animation,_extends({toValue:g},a)).start(0===u&&n.onRest)},d.stop=function(){return d.animation.stopAnimation()},e&&d.start(),n.interpolators[p]=d.interpolation,_extends({},t,((h={})[p]=d,h))},{});var h=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),h&&h.__detach()},n.componentWillReceiveProps=function(t){this.update(t,!0)},n.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},n.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},a,r,{children:e})):e(_extends({},a,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1};var _initialiseProps=function(){var t=this;this.callback=function(){t.props.onFrame&&t.props.onFrame(t.propsAnimated.__getValue()),!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},ref=function(t,e){return"function"==typeof t?t(e):t},Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.items,s=e.from,l=e.enter,u=(e.leave,e.update);return i=r||i,"function"==typeof a&&(a=o.map(a)),Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionKeys:a,transitions:i.map(function(t,e){var n=o?o[e]:a[e];return{children:t,key:a[e],item:n,to:ref(l,n),from:ref(s,n),update:ref(u,n)}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionKeys,a=t.children,o=t.render,s=t.keys,l=t.items,u=t.from,c=t.enter,h=t.leave,p=t.update;a=o||a,"function"==typeof s&&(s=l.map(s)),Array.isArray(a)||(a=[a],s=s?[s]:a);var f=new Set(s),d=new Set(r),m=s.filter(function(t){return!d.has(t)}),_=r.filter(function(t){return!f.has(t)}),v=s.filter(function(t){return d.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n),p&&-1!==v.indexOf(t.key)&&(t.to=ref(p,l?l[e]:s[e])||t.to)}return t}),m.length&&m.forEach(function(t){var e=s.indexOf(t),n=a[e],r=l?l[e]:s[e],o={children:n,key:s[e],item:r,to:ref(c,r),from:ref(u,r)};i=i.slice(0,e).concat([o],i.slice(e))}),_.length&&_.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:ref(h,n.item),from:ref(u,n.item),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var g=s.map(function(t){return i.find(function(e){return e.key===t})});_.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(g=g.slice(0,e).concat([n],g.slice(e)))}),this.setState({transitions:g,transitionKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.items,e.onFrame),o=_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","items","onFrame"]));return this.state.transitions.map(function(e){var i=e.key,r=e.item,s=e.children,l=_objectWithoutProperties(e,["key","item","children"]);return React.createElement(Spring,_extends({key:i},l,o,{onFrame:a&&function(t){return a(r,t)},render:n&&s,children:n?t.props.children:s}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default};var _class,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,r=t.to,a=t.native,o=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),u=new Set,c=_extends({},l,{native:a,config:o,from:i,to:r});return(n||e).map(function(t,i){return React.createElement(Spring,_extends({key:s[i]},c,{attach:function(t){return function(t,e){return u.add(e),0===t?void 0:Array.from(u)[t-1]}(i,t)},render:n&&t,children:n?e:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps$1.call(_assertThisInitialized(n)),n.state={ready:!1},n.layers=[],n.space=0,n.current=0,n.offset=0,n.busy=!1,n}_inheritsLoose(e,t);var n=e.prototype;return n.scrollTo=function(t){var e=this.props,n=e.horizontal,i=e.config;this.scrollStop(),this.offset=t;var r=this.refs.container;this.animatedScroll=new exports$2.Value(r[n?"scrollLeft":"scrollTop"]),this.animatedScroll.addListener(function(t){var e=t.value;return r[n?"scrollLeft":"scrollTop"]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,u=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:u,overflowY:l?"hidden":u,overflowX:l?u:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class.contextTypes={parallax:PropTypes.object},_class.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps$1=function(){var t=this;this.moveItems=function(){t.layers.forEach(function(e){return e.setPosition(t.space,t.current)}),t.busy=!1},this.scrollerRaf=function(){return requestAnimationFrame(t.moveItems)},this.onScroll=function(e){var n=t.props.horizontal;t.busy||(t.busy=!0,t.scrollerRaf(),t.current=e.target[n?"scrollLeft":"scrollTop"])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal;t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[i?"scrollLeft":"scrollTop"]:t.refs.container[i?"scrollLeft":"scrollTop"]=t.current=t.offset*t.space,t.refs.content&&(t.refs.content.style[i?"width":"height"]=t.space*t.props.pages+"px"),t.layers.forEach(function(e){e.setHeight(t.space,!0),e.setPosition(t.space,t.current,!0)}))},this.updateRaf=function(){requestAnimationFrame(t.update),setTimeout(t.update,150)},this.scrollStop=function(e){return t.animatedScroll&&t.animatedScroll.stopAnimation()}};export{Spring,Transition,Trail,Parallax,config,template,animated,interpolate$1 as interpolate}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var normalizeColor=_interopDefault(require("normalize-css-color")),React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types"));function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),_class=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(_class),_class$1=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}();function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var _class$2=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){0===this._animatedStyles.size&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){this._value=t,this._flush()},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(_class),_class$3=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new _class$2(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(_class),_class$4=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(_class),_class$5=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this).onUpdate=function(){var t=Date.now();t>n._lastTime+64&&(t=n._lastTime+64);var e=(t-n._lastTime)/1e3;n._frameTime+=e;var i=n._friction,r=n._mass,a=n._tension,o=-n._initialVelocity,s=i/(2*Math.sqrt(a*r)),l=Math.sqrt(a/r),c=l*Math.sqrt(1-s*s),u=n._toValue-n._startPosition,p=0,f=0,h=n._frameTime;if(s<1){var d=Math.exp(-s*l*h);p=n._toValue-d*((o+s*l*u)/c*Math.sin(c*h)+u*Math.cos(c*h)),f=s*l*d*(Math.sin(c*h)*(o+s*l*u)/c+u*Math.cos(c*h))-d*(Math.cos(c*h)*(o+s*l*u)-c*u*Math.sin(c*h))}else{var _=Math.exp(-l*h);p=n._toValue-_*(u+(o+l*u)*h),f=_*(o*(h*l-1)+h*u*(l*l))}if(n._lastTime=t,n._lastPosition=p,n._lastVelocity=f,n._onUpdate(p),n.__active){var m=!1;n._overshootClamping&&0!==n._stiffness&&(m=n._startPosition<n._toValue?p>n._toValue:p<n._toValue);var v=Math.abs(f)<=n._restSpeedThreshold,g=!0;if(0!==n._stiffness&&(g=Math.abs(n._toValue-p)<=n._restDisplacementThreshold),m||v&&g)return 0!==n._stiffness&&(n._lastPosition=n._toValue,n._lastVelocity=0,n._onUpdate(n._toValue)),n.__debouncedOnEnd({finished:!0});n._animationFrame=RequestAnimationFrame.current(n.onUpdate)}},n._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,1e-4),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,1e-4),n._initialVelocity=withDefault(e.velocity,0),n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n._mass=withDefault(e.mass,1),n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),this._frameTime=0,r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(_class$1),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},_class$6=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(_class),_class$7=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new _class$6(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new _class$7(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof _class$3?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new _class$5(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:_class$2,Array:_class$3,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new _class$4(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:_class$7},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return n=t.call(this)||this,_initialiseProps.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n.update=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset;t.onUpdate;void 0===e&&(e=!1);var c=Object.entries(_extends({},i,r)),u=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(t,r,c){var p,f=r[0],h=r[1],d=!1===l&&n.animations[f]||(n.animations[f]={}),_="number"==typeof h,m=!_&&Array.isArray(h),v=void 0!==i[f]?i[f]:h,g=_||m?h:1;if(_&&o){var y=o(n),A=y&&y.animations[f];A&&(g=A.animation)}if(_)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(m)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(u);d.animation=n.defaultAnimation,d.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,h]})}return!s||!0!==s&&-1===s.indexOf(f)||d.animation.setValue(g),d.start=function(){return exports$2.spring(d.animation,_extends({toValue:g},a)).start(0===c&&n.onRest)},d.stop=function(){return d.animation.stopAnimation()},e&&d.start(),n.interpolators[f]=d.interpolation,_extends({},t,((p={})[f]=d,p))},{});var p=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),p&&p.__detach()},n.componentWillReceiveProps=function(t){this.update(t,!0)},n.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},n.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},a,r,{children:e})):e(_extends({},a,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1};var _initialiseProps=function(){var t=this;this.callback=function(){t.props.onUpdate&&t.props.onUpdate(t.propsAnimated.__getValue()),!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},callOrRefer=function(t,e){return"function"==typeof t?t(e):t},Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.from,s=e.enter,l=(e.leave,e.update);e.accessor;return i=r||i,Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionsKeys:a,transitions:i.map(function(t,e){return{children:t,key:a[e],to:callOrRefer(s,a[e]),from:callOrRefer(o,a[e]),update:callOrRefer(l,a[e])}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionsKeys,a=t.children,o=t.render,s=t.keys,l=t.from,c=t.enter,u=t.leave,p=t.update,f=t.accessor;a=o||a,Array.isArray(a)||(a=[a],s=s?[s]:a);var h=s.map(function(t){return f(t)}),d=r.map(function(t){return f(t)}),_=new Set(h),m=new Set(d),v=h.filter(function(t){return!m.has(t)}),g=d.filter(function(t){return!_.has(t)}),y=h.filter(function(t){return m.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=h.indexOf(f(t.key)),n=a[e];n&&(t.children=n),p&&-1!==y.indexOf(f(t.key))&&(t.to=callOrRefer(p,s[e])||t.to)}return t}),v.length&&v.forEach(function(t){var e=h.indexOf(t),n={children:a[e],key:s[e],to:callOrRefer(c,s[e]),from:callOrRefer(l,s[e])};i=i.slice(0,e).concat([n],i.slice(e))}),g.length&&g.forEach(function(t){var n=i.find(function(e){return f(e.key)===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:callOrRefer(u,n.key),from:callOrRefer(l,n.key),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var A=s.map(function(t){return i.find(function(e){return f(e.key)===f(t)})});g.forEach(function(t){var e=i.findIndex(function(e){return f(e.key)===t}),n=i.find(function(e){return f(e.key)===t});n&&(A=A.slice(0,e).concat([n],A.slice(e)))}),this.setState({transitions:A,transitionsKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.accessor),o=e.onUpdate,s=_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","accessor","onUpdate"]));return this.state.transitions.map(function(e){var i=e.key,r=e.children,l=_objectWithoutProperties(e,["key","children"]);return React.createElement(Spring,_extends({key:a(i)},l,s,{onUpdate:o&&function(t){return o(i,t)},render:n&&r,children:n?t.props.children:r}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default,accessor:function(t){return t}};var _class$8,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,r=t.to,a=t.native,o=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),c=new Set,u=_extends({},l,{native:a,config:o,from:i,to:r});return(n||e).map(function(t,i){return React.createElement(Spring,_extends({key:s[i]},u,{attach:function(t){return function(t,e){return c.add(e),0===t?void 0:Array.from(c)[t-1]}(i,t)},render:n&&t,children:n?e:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps$1.call(_assertThisInitialized(n)),n.state={ready:!1},n.layers=[],n.space=0,n.current=0,n.offset=0,n.busy=!1,n}_inheritsLoose(e,t);var n=e.prototype;return n.scrollTo=function(t){var e=this.props,n=e.horizontal,i=e.config;this.scrollStop(),this.offset=t;var r=this.refs.container;this.animatedScroll=new exports$2.Value(r[n?"scrollLeft":"scrollTop"]),this.animatedScroll.addListener(function(t){var e=t.value;return r[n?"scrollLeft":"scrollTop"]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,c=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:c,overflowY:l?"hidden":c,overflowX:l?c:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class$8=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class$8.contextTypes={parallax:PropTypes.object},_class$8.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps$1=function(){var t=this;this.moveItems=function(){t.layers.forEach(function(e){return e.setPosition(t.space,t.current)}),t.busy=!1},this.scrollerRaf=function(){return requestAnimationFrame(t.moveItems)},this.onScroll=function(e){var n=t.props.horizontal;t.busy||(t.busy=!0,t.scrollerRaf(),t.current=e.target[n?"scrollLeft":"scrollTop"])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal;t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[i?"scrollLeft":"scrollTop"]:t.refs.container[i?"scrollLeft":"scrollTop"]=t.current=t.offset*t.space,t.refs.content&&(t.refs.content.style[i?"width":"height"]=t.space*t.props.pages+"px"),t.layers.forEach(function(e){e.setHeight(t.space,!0),e.setPosition(t.space,t.current,!0)}))},this.updateRaf=function(){requestAnimationFrame(t.update),setTimeout(t.update,150)},this.scrollStop=function(e){return t.animatedScroll&&t.animatedScroll.stopAnimation()}};exports.Spring=Spring,exports.Transition=Transition,exports.Trail=Trail,exports.Parallax=Parallax,exports.config=config,exports.template=template,exports.animated=animated,exports.interpolate=interpolate$1; | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var normalizeColor=_interopDefault(require("normalize-css-color")),React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types"));function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o._hey=1,o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){t instanceof AnimatedTracking&&(this._tracked=!0),0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(AnimatedWithChildren),Animation=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}(),_uniqueId=0;function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){(0===this._animatedStyles.size||this._tracked)&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){for(var e in this._value=t,this._flush(),this._listeners)this._listeners[e]({value:this.__getValue()})},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.addListener=function(t){var e=String(_uniqueId++);return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new AnimatedValue(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var a=Math.floor((r-this._lastTime)/1),o=0;o<a;++o){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,u=(n=t+.001*s/2,i=e+.001*l/2),c=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*u/2;var p=i=e+.001*c/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(u+p)+h)/6),e+=.001*((l+2*(c+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var m=!1;this._overshootClamping&&0!==this._tension&&(m=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var _=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),m||_&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof AnimatedArray?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return n=t.call(this)||this,_initialiseProps.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n.update=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset;t.onFrame;void 0===e&&(e=!1);var u=Object.entries(_extends({},i,r)),c=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=u.reduce(function(t,r,u){var p,f=r[0],h=r[1],d=!1===l&&n.animations[f]||(n.animations[f]={}),m="number"==typeof h,_=!m&&Array.isArray(h),v=void 0!==i[f]?i[f]:h,g=m||_?h:1;if(m&&o){var y=o(n),A=y&&y.animations[f];A&&(g=A.animation)}if(m)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(_)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(c);d.animation=n.defaultAnimation,d.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,h]})}return!s||!0!==s&&-1===s.indexOf(f)||d.animation.setValue(g),d.start=function(){return exports$2.spring(d.animation,_extends({toValue:g},a)).start(0===u&&n.onRest)},d.stop=function(){return d.animation.stopAnimation()},e&&d.start(),n.interpolators[f]=d.interpolation,_extends({},t,((p={})[f]=d,p))},{});var p=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),p&&p.__detach()},n.componentWillReceiveProps=function(t){this.update(t,!0)},n.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},n.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},a,r,{children:e})):e(_extends({},a,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1};var _initialiseProps=function(){var t=this;this.callback=function(){t.props.onFrame&&t.props.onFrame(t.propsAnimated.__getValue()),!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},ref=function(t,e){return"function"==typeof t?t(e):t},Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.items,s=e.from,l=e.enter,u=(e.leave,e.update);return i=r||i,"function"==typeof a&&(a=o.map(a)),Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionKeys:a,transitions:i.map(function(t,e){var n=o?o[e]:a[e];return{children:t,key:a[e],item:n,to:ref(l,n),from:ref(s,n),update:ref(u,n)}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionKeys,a=t.children,o=t.render,s=t.keys,l=t.items,u=t.from,c=t.enter,p=t.leave,f=t.update;a=o||a,"function"==typeof s&&(s=l.map(s)),Array.isArray(a)||(a=[a],s=s?[s]:a);var h=new Set(s),d=new Set(r),m=s.filter(function(t){return!d.has(t)}),_=r.filter(function(t){return!h.has(t)}),v=s.filter(function(t){return d.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n),f&&-1!==v.indexOf(t.key)&&(t.to=ref(f,l?l[e]:s[e])||t.to)}return t}),m.length&&m.forEach(function(t){var e=s.indexOf(t),n=a[e],r=l?l[e]:s[e],o={children:n,key:s[e],item:r,to:ref(c,r),from:ref(u,r)};i=i.slice(0,e).concat([o],i.slice(e))}),_.length&&_.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:ref(p,n.item),from:ref(u,n.item),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var g=s.map(function(t){return i.find(function(e){return e.key===t})});_.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(g=g.slice(0,e).concat([n],g.slice(e)))}),this.setState({transitions:g,transitionKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.items,e.onFrame),o=_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","items","onFrame"]));return this.state.transitions.map(function(e){var i=e.key,r=e.item,s=e.children,l=_objectWithoutProperties(e,["key","item","children"]);return React.createElement(Spring,_extends({key:i},l,o,{onFrame:a&&function(t){return a(r,t)},render:n&&s,children:n?t.props.children:s}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default};var _class,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,r=t.to,a=t.native,o=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),u=new Set,c=_extends({},l,{native:a,config:o,from:i,to:r});return(n||e).map(function(t,i){return React.createElement(Spring,_extends({key:s[i]},c,{attach:function(t){return function(t,e){return u.add(e),0===t?void 0:Array.from(u)[t-1]}(i,t)},render:n&&t,children:n?e:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps$1.call(_assertThisInitialized(n)),n.state={ready:!1},n.layers=[],n.space=0,n.current=0,n.offset=0,n.busy=!1,n}_inheritsLoose(e,t);var n=e.prototype;return n.scrollTo=function(t){var e=this.props,n=e.horizontal,i=e.config;this.scrollStop(),this.offset=t;var r=this.refs.container;this.animatedScroll=new exports$2.Value(r[n?"scrollLeft":"scrollTop"]),this.animatedScroll.addListener(function(t){var e=t.value;return r[n?"scrollLeft":"scrollTop"]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,u=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:u,overflowY:l?"hidden":u,overflowX:l?u:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class.contextTypes={parallax:PropTypes.object},_class.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps$1=function(){var t=this;this.moveItems=function(){t.layers.forEach(function(e){return e.setPosition(t.space,t.current)}),t.busy=!1},this.scrollerRaf=function(){return requestAnimationFrame(t.moveItems)},this.onScroll=function(e){var n=t.props.horizontal;t.busy||(t.busy=!0,t.scrollerRaf(),t.current=e.target[n?"scrollLeft":"scrollTop"])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal;t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[i?"scrollLeft":"scrollTop"]:t.refs.container[i?"scrollLeft":"scrollTop"]=t.current=t.offset*t.space,t.refs.content&&(t.refs.content.style[i?"width":"height"]=t.space*t.props.pages+"px"),t.layers.forEach(function(e){e.setHeight(t.space,!0),e.setPosition(t.space,t.current,!0)}))},this.updateRaf=function(){requestAnimationFrame(t.update),setTimeout(t.update,150)},this.scrollStop=function(e){return t.animatedScroll&&t.animatedScroll.stopAnimation()}};exports.Spring=Spring,exports.Transition=Transition,exports.Trail=Trail,exports.Parallax=Parallax,exports.config=config,exports.template=template,exports.animated=animated,exports.interpolate=interpolate$1; |
{ | ||
"name": "react-spring", | ||
"version": "3.2.0-beta.11", | ||
"version": "3.2.0-beta.12", | ||
"description": "Animate React with ease", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-spring", |
@@ -1,2 +0,2 @@ | ||
class Animated { | ||
export default class Animated { | ||
__attach() {} | ||
@@ -14,3 +14,1 @@ __detach() {} | ||
} | ||
export default Animated |
@@ -5,3 +5,3 @@ import Animated from './Animated' | ||
export default class extends AnimatedWithChildren { | ||
export default class AnimatedArray extends AnimatedWithChildren { | ||
constructor(array) { | ||
@@ -8,0 +8,0 @@ super() |
import Animated from './Animated' | ||
import AnimatedStyle from './AnimatedStyle' | ||
export default class extends Animated { | ||
export default class AnimatedProps extends Animated { | ||
constructor(props, callback) { | ||
@@ -6,0 +6,0 @@ super() |
@@ -5,3 +5,3 @@ import Animated from './Animated' | ||
export default class extends AnimatedWithChildren { | ||
export default class AnimatedStyle extends AnimatedWithChildren { | ||
constructor(style) { | ||
@@ -8,0 +8,0 @@ super() |
import Animated from './Animated' | ||
import AnimatedWithChildren from './AnimatedWithChildren' | ||
export default class extends AnimatedWithChildren { | ||
export default class AnimatedTemplate extends AnimatedWithChildren { | ||
constructor(strings, values) { | ||
@@ -6,0 +6,0 @@ super() |
import Animated from './Animated' | ||
import AnimatedValue from './AnimatedValue' | ||
export default class extends Animated { | ||
export default class AnimatedTracking extends Animated { | ||
constructor(value, parent, animationClass, animationConfig, callback) { | ||
@@ -13,2 +13,4 @@ super() | ||
this.__attach() | ||
this._hey = 1 | ||
} | ||
@@ -15,0 +17,0 @@ |
@@ -6,2 +6,4 @@ import AnimatedWithChildren from './AnimatedWithChildren' | ||
var _uniqueId = 0 | ||
/** | ||
@@ -41,3 +43,3 @@ * Animated works by building a directed acyclic graph of dependencies | ||
*/ | ||
export default class extends AnimatedWithChildren { | ||
export default class AnimatedValue extends AnimatedWithChildren { | ||
constructor(value) { | ||
@@ -48,2 +50,3 @@ super() | ||
this._animatedStyles = new Set() | ||
this._listeners = {} | ||
} | ||
@@ -60,3 +63,3 @@ | ||
_flush() { | ||
if (this._animatedStyles.size === 0) findAnimatedStyles(this, this._animatedStyles) | ||
if (this._animatedStyles.size === 0 || this._tracked) findAnimatedStyles(this, this._animatedStyles) | ||
this._animatedStyles.forEach(animatedStyle => animatedStyle.update()) | ||
@@ -68,2 +71,3 @@ } | ||
this._flush() | ||
for (var key in this._listeners) this._listeners[key]({ value: this.__getValue() }) | ||
} | ||
@@ -125,2 +129,21 @@ | ||
/** | ||
* Adds an asynchronous listener to the value so you can observe updates from | ||
* animations. This is useful because there is no way to | ||
* synchronously read the value because it might be driven natively. | ||
*/ | ||
addListener(callback) { | ||
var id = String(_uniqueId++) | ||
this._listeners[id] = callback | ||
return id | ||
} | ||
removeListener(id) { | ||
delete this._listeners[id] | ||
} | ||
removeAllListeners() { | ||
this._listeners = {} | ||
} | ||
/** | ||
* Typically only used internally. | ||
@@ -127,0 +150,0 @@ */ |
import Animated from './Animated' | ||
import AnimatedTracking from './AnimatedTracking' | ||
export default class extends Animated { | ||
export default class AnimatedWithChildren extends Animated { | ||
constructor() { | ||
@@ -10,2 +11,3 @@ super() | ||
__addChild(child) { | ||
if (child instanceof AnimatedTracking) this._tracked = true | ||
if (this._children.length === 0) this.__attach() | ||
@@ -12,0 +14,0 @@ this._children.push(child) |
// Important note: start() and stop() will only be called at most once. | ||
// Once an animation has been stopped or finished its course, it will | ||
// not be reused. | ||
export default class { | ||
export default class Animation { | ||
start(fromValue, onUpdate, onEnd, previousAnimation) {} | ||
@@ -6,0 +6,0 @@ |
@@ -7,3 +7,3 @@ import React from 'react' | ||
export default function(Component) { | ||
export default function createAnimatedComponent(Component) { | ||
return class AnimatedComponent extends React.Component { | ||
@@ -10,0 +10,0 @@ static propTypes = { |
@@ -93,2 +93,2 @@ import Animated from './Animated' | ||
export default exports | ||
export default exports |
@@ -9,3 +9,3 @@ import normalizeColor from 'normalize-css-color' | ||
*/ | ||
class Interpolation { | ||
export default class Interpolation { | ||
static create(config) { | ||
@@ -181,3 +181,1 @@ if (typeof config === 'function') return input => config(input) | ||
} | ||
export default Interpolation |
@@ -7,3 +7,3 @@ import Animation from './Animation' | ||
const withDefault = (value, defaultValue) => (value === undefined || value === null ? defaultValue : value) | ||
const withDefault = (value, defaultValue) => value === undefined || value === null ? defaultValue : value | ||
@@ -14,11 +14,11 @@ export default class SpringAnimation extends Animation { | ||
this._overshootClamping = withDefault(config.overshootClamping, false) | ||
this._restDisplacementThreshold = withDefault(config.restDisplacementThreshold, 0.0001) | ||
this._restSpeedThreshold = withDefault(config.restSpeedThreshold, 0.0001) | ||
this._initialVelocity = withDefault(config.velocity, 0) | ||
this._restDisplacementThreshold = withDefault(config.restDisplacementThreshold, 0.001) | ||
this._restSpeedThreshold = withDefault(config.restSpeedThreshold, 0.001) | ||
this._initialVelocity = config.velocity | ||
this._lastVelocity = withDefault(config.velocity, 0) | ||
this._toValue = config.toValue | ||
this.__isInteraction = config.isInteraction !== undefined ? config.isInteraction : true | ||
var springConfig = SpringConfig.fromOrigamiTensionAndFriction(withDefault(config.tension, 40), withDefault(config.friction, 7)) | ||
this._tension = springConfig.tension | ||
this._friction = springConfig.friction | ||
this._mass = withDefault(config.mass, 1); | ||
} | ||
@@ -33,3 +33,2 @@ | ||
this._lastTime = Date.now() | ||
this._frameTime = 0.0 | ||
@@ -52,3 +51,8 @@ if (previousAnimation instanceof SpringAnimation) { | ||
onUpdate = () => { | ||
onUpdate() { | ||
var position = this._lastPosition | ||
var velocity = this._lastVelocity | ||
var tempPosition = this._lastPosition | ||
var tempVelocity = this._lastVelocity | ||
// If for some reason we lost a lot of frames (e.g. process large payload or | ||
@@ -58,38 +62,39 @@ // stopped in the debugger), we only advance by 4 frames worth of | ||
// running at faster speed than jumping to the end. | ||
const MAX_STEPS = 64 | ||
let now = Date.now() | ||
if (now > this._lastTime + MAX_STEPS) { | ||
now = this._lastTime + MAX_STEPS | ||
} | ||
var MAX_STEPS = 64 | ||
var now = Date.now() | ||
const deltaTime = (now - this._lastTime) / 1000 | ||
this._frameTime += deltaTime | ||
if (now > this._lastTime + MAX_STEPS) now = this._lastTime + MAX_STEPS | ||
const c = this._friction | ||
const m = this._mass | ||
const k = this._tension | ||
const v0 = -this._initialVelocity | ||
// We are using a fixed time step and a maximum number of iterations. | ||
// The following post provides a lot of thoughts into how to build this | ||
// loop: http://gafferongames.com/game-physics/fix-your-timestep/ | ||
var TIMESTEP_MSEC = 1 | ||
var numSteps = Math.floor((now - this._lastTime) / TIMESTEP_MSEC) | ||
const zeta = c / (2 * Math.sqrt(k * m)) // damping ratio | ||
const omega0 = Math.sqrt(k / m) // undamped angular frequency of the oscillator (rad/ms) | ||
const omega1 = omega0 * Math.sqrt(1.0 - zeta * zeta) // exponential decay | ||
const x0 = this._toValue - this._startPosition // calculate the oscillation from x0 = 1 to x = 0 | ||
for (var i = 0; i < numSteps; ++i) { | ||
// Velocity is based on seconds instead of milliseconds | ||
var step = TIMESTEP_MSEC / 1000 | ||
let position = 0.0 | ||
let velocity = 0.0 | ||
const t = this._frameTime | ||
if (zeta < 1) { | ||
// Under damped | ||
const envelope = Math.exp(-zeta * omega0 * t) | ||
position = this._toValue - envelope * ((v0 + zeta * omega0 * x0) / omega1 * Math.sin(omega1 * t) + x0 * Math.cos(omega1 * t)) | ||
// This looks crazy -- it's actually just the derivative of the | ||
// oscillation function | ||
velocity = | ||
zeta * omega0 * envelope * (Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0) / omega1 + x0 * Math.cos(omega1 * t)) - | ||
envelope * (Math.cos(omega1 * t) * (v0 + zeta * omega0 * x0) - omega1 * x0 * Math.sin(omega1 * t)) | ||
} else { | ||
// Critically damped | ||
const envelope = Math.exp(-omega0 * t) | ||
position = this._toValue - envelope * (x0 + (v0 + omega0 * x0) * t) | ||
velocity = envelope * (v0 * (t * omega0 - 1) + t * x0 * (omega0 * omega0)) | ||
// This is using RK4. A good blog post to understand how it works: | ||
// http://gafferongames.com/game-physics/integration-basics/ | ||
var aVelocity = velocity | ||
var aAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity | ||
var tempPosition = position + aVelocity * step / 2 | ||
var tempVelocity = velocity + aAcceleration * step / 2 | ||
var bVelocity = tempVelocity | ||
var bAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity | ||
tempPosition = position + bVelocity * step / 2 | ||
tempVelocity = velocity + bAcceleration * step / 2 | ||
var cVelocity = tempVelocity | ||
var cAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity | ||
tempPosition = position + cVelocity * step / 2 | ||
tempVelocity = velocity + cAcceleration * step / 2 | ||
var dVelocity = tempVelocity | ||
var dAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity | ||
tempPosition = position + cVelocity * step / 2 | ||
tempVelocity = velocity + cAcceleration * step / 2 | ||
var dxdt = (aVelocity + 2 * (bVelocity + cVelocity) + dVelocity) / 6 | ||
var dvdt = (aAcceleration + 2 * (bAcceleration + cAcceleration) + dAcceleration) / 6 | ||
position += dxdt * step | ||
velocity += dvdt * step | ||
} | ||
@@ -107,22 +112,21 @@ | ||
// Conditions for stopping the spring animation | ||
let isOvershooting = false | ||
if (this._overshootClamping && this._stiffness !== 0) { | ||
isOvershooting = this._startPosition < this._toValue ? position > this._toValue : position < this._toValue | ||
var isOvershooting = false | ||
if (this._overshootClamping && this._tension !== 0) { | ||
if (this._startPosition < this._toValue) { | ||
isOvershooting = position > this._toValue | ||
} else { | ||
isOvershooting = position < this._toValue | ||
} | ||
} | ||
const isVelocity = Math.abs(velocity) <= this._restSpeedThreshold | ||
let isDisplacement = true | ||
if (this._stiffness !== 0) { | ||
isDisplacement = Math.abs(this._toValue - position) <= this._restDisplacementThreshold | ||
} | ||
var isVelocity = Math.abs(velocity) <= this._restSpeedThreshold | ||
var isDisplacement = true | ||
if (this._tension !== 0) isDisplacement = Math.abs(this._toValue - position) <= this._restDisplacementThreshold | ||
if (isOvershooting || (isVelocity && isDisplacement)) { | ||
if (this._stiffness !== 0) { | ||
// Ensure that we end up with a round value | ||
this._lastPosition = this._toValue | ||
this._lastVelocity = 0 | ||
this._onUpdate(this._toValue) | ||
} | ||
return this.__debouncedOnEnd({ finished: true }) | ||
// Ensure that we end up with a round value | ||
if (this._tension !== 0) this._onUpdate(this._toValue) | ||
this.__debouncedOnEnd({ finished: true }) | ||
return | ||
} | ||
this._animationFrame = RequestAnimationFrame.current(this.onUpdate) | ||
this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this)) | ||
} | ||
@@ -135,2 +139,2 @@ | ||
} | ||
} | ||
} |
@@ -25,3 +25,3 @@ import React from 'react' | ||
onRest: PropTypes.func, | ||
onUpdate: PropTypes.func, | ||
onFrame: PropTypes.func, | ||
children: PropTypes.func, | ||
@@ -41,3 +41,3 @@ render: PropTypes.func, | ||
update({ from, to, config, attach, immediate, reset, onUpdate }, start = false) { | ||
update({ from, to, config, attach, immediate, reset, onFrame }, start = false) { | ||
const allProps = Object.entries({ ...from, ...to }) | ||
@@ -94,3 +94,3 @@ const defaultAnimationValue = this.defaultAnimation._value | ||
callback = () => { | ||
if (this.props.onUpdate) this.props.onUpdate(this.propsAnimated.__getValue()) | ||
if (this.props.onFrame) this.props.onFrame(this.propsAnimated.__getValue()) | ||
!this.props.native && this.forceUpdate() | ||
@@ -97,0 +97,0 @@ } |
@@ -6,3 +6,3 @@ import React from 'react' | ||
const callOrRefer = (object, key) => (typeof object === 'function' ? object(key) : object) | ||
const ref = (object, key) => (typeof object === 'function' ? object(key) : object) | ||
@@ -18,6 +18,10 @@ export default class Transition extends React.PureComponent { | ||
keys: PropTypes.oneOfType([ | ||
PropTypes.func, | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), | ||
PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
]), | ||
items: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object])), | ||
PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]), | ||
]), | ||
accessor: PropTypes.func, | ||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]), | ||
@@ -27,8 +31,9 @@ render: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]), | ||
static defaultProps = { from: {}, enter: {}, leave: {}, native: false, config: config.default, accessor: item => item } | ||
static defaultProps = { from: {}, enter: {}, leave: {}, native: false, config: config.default } | ||
constructor(props) { | ||
super() | ||
let { children, render, keys, from, enter, leave, update, accessor } = props | ||
let { children, render, keys, items, from, enter, leave, update } = props | ||
children = render || children | ||
if (typeof keys === 'function') keys = items.map(keys) | ||
if (!Array.isArray(children)) { | ||
@@ -39,10 +44,7 @@ children = [children] | ||
this.state = { | ||
transitionsKeys: keys, | ||
transitions: children.map((child, i) => ({ | ||
children: child, | ||
key: keys[i], | ||
to: callOrRefer(enter, keys[i]), | ||
from: callOrRefer(from, keys[i]), | ||
update: callOrRefer(update, keys[i]), | ||
})), | ||
transitionKeys: keys, | ||
transitions: children.map((child, i) => { | ||
const arg = items ? items[i] : keys[i] | ||
return { children: child, key: keys[i], item: arg, to: ref(enter, arg), from: ref(from, arg), update: ref(update, arg) } | ||
}), | ||
} | ||
@@ -52,5 +54,6 @@ } | ||
componentWillReceiveProps(props) { | ||
let { transitions, transitionsKeys } = this.state | ||
let { children, render, keys, from, enter, leave, update, accessor } = props | ||
let { transitions, transitionKeys } = this.state | ||
let { children, render, keys, items, from, enter, leave, update } = props | ||
children = render || children | ||
if (typeof keys === 'function') keys = items.map(keys) | ||
if (!Array.isArray(children)) { | ||
@@ -62,9 +65,7 @@ children = [children] | ||
// Compare next keys with current keys | ||
let keysAccess = keys.map(key => accessor(key)) | ||
let transitionKeysAccess = transitionsKeys.map(key => accessor(key)) | ||
let nextSet = new Set(keysAccess) | ||
let currentSet = new Set(transitionKeysAccess) | ||
let added = keysAccess.filter(item => !currentSet.has(item)) | ||
let deleted = transitionKeysAccess.filter(item => !nextSet.has(item)) | ||
let rest = keysAccess.filter(item => currentSet.has(item)) | ||
let nextSet = new Set(keys) | ||
let currentSet = new Set(transitionKeys) | ||
let added = keys.filter(item => !currentSet.has(item)) | ||
let deleted = transitionKeys.filter(item => !nextSet.has(item)) | ||
let rest = keys.filter(item => currentSet.has(item)) | ||
@@ -74,7 +75,7 @@ // Update child functions | ||
if (transition.destroy === undefined) { | ||
const index = keysAccess.indexOf(accessor(transition.key)) | ||
const index = keys.indexOf(transition.key) | ||
const updatedChild = children[index] | ||
if (updatedChild) transition.children = updatedChild | ||
if (update && rest.indexOf(accessor(transition.key)) !== -1) | ||
transition.to = callOrRefer(update, keys[index]) || transition.to | ||
if (update && rest.indexOf(transition.key) !== -1) | ||
transition.to = ref(update, items ? items[index] : keys[index]) || transition.to | ||
} | ||
@@ -87,10 +88,6 @@ return transition | ||
added.forEach(key => { | ||
const index = keysAccess.indexOf(key) | ||
const index = keys.indexOf(key) | ||
const child = children[index] | ||
const addedChild = { | ||
children: child, | ||
key: keys[index], | ||
to: callOrRefer(enter, keys[index]), | ||
from: callOrRefer(from, keys[index]), | ||
} | ||
const arg = items ? items[index] : keys[index] | ||
const addedChild = { children: child, key: keys[index], item: arg, to: ref(enter, arg), from: ref(from, arg) } | ||
transitions = [...transitions.slice(0, index), addedChild, ...transitions.slice(index)] | ||
@@ -103,3 +100,3 @@ }) | ||
deleted.forEach(key => { | ||
const oldChild = transitions.find(child => accessor(child.key) === key) | ||
const oldChild = transitions.find(child => child.key === key) | ||
if (oldChild) { | ||
@@ -110,4 +107,4 @@ const leavingChild = { | ||
key: oldChild.key, | ||
to: callOrRefer(leave, oldChild.key), | ||
from: callOrRefer(from, oldChild.key), | ||
to: ref(leave, oldChild.item), | ||
from: ref(from, oldChild.item), | ||
onRest: () => this.setState(state => ({ transitions: state.transitions.filter(child => child !== leavingChild) })), | ||
@@ -121,9 +118,9 @@ } | ||
// Update transition keys, remove leaving children | ||
transitionsKeys = transitions.filter(child => child.destroy === undefined).map(child => child.key) | ||
transitionKeys = transitions.filter(child => child.destroy === undefined).map(child => child.key) | ||
// Re-order list | ||
let ordered = keys.map(key => transitions.find(child => accessor(child.key) === accessor(key))) | ||
let ordered = keys.map(key => transitions.find(child => child.key === key)) | ||
deleted.forEach(key => { | ||
let index = transitions.findIndex(child => accessor(child.key) === key) | ||
let child = transitions.find(child => accessor(child.key) === key) | ||
let index = transitions.findIndex(child => child.key === key) | ||
let child = transitions.find(child => child.key === key) | ||
if (child) ordered = [...ordered.slice(0, index), child, ...ordered.slice(index)] | ||
@@ -133,14 +130,14 @@ }) | ||
// Push new state | ||
this.setState({ transitions: ordered, transitionsKeys }) | ||
this.setState({ transitions: ordered, transitionKeys }) | ||
} | ||
render() { | ||
const { render, from, enter, leave, native, config, keys, accessor, onUpdate, ...extra } = this.props | ||
const { render, from, enter, leave, native, config, keys, items, onFrame, ...extra } = this.props | ||
const props = { native, config, ...extra } | ||
return this.state.transitions.map(({ key, children, ...rest }) => ( | ||
return this.state.transitions.map(({ key, item, children, ...rest }) => ( | ||
<Spring | ||
key={accessor(key)} | ||
key={key} | ||
{...rest} | ||
{...props} | ||
onUpdate={onUpdate && (values => onUpdate(key, values))} | ||
onFrame={onFrame && (values => onFrame(item, values))} | ||
render={render && children} | ||
@@ -147,0 +144,0 @@ children={render ? this.props.children : children} |
206549
1811