react-spring
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -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={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[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}(),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){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),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){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 o="extend";return void 0!==t.extrapolateRight?o=t.extrapolateRight:void 0!==t.extrapolate&&(o=t.extrapolate),function(t){var a=findRange(t,n);return interpolate(t,n[a],n[a+1],e[a],e[a+1],i,r,o)}},t}();function interpolate(t,e,n,i,r,o,a,s){var l=t;if(l<e){if("identity"===a)return l;"clamp"===a&&(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=o(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 _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},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}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},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,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},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._listeners={},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.setOffset=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setOffset(t)})},n.flattenOffset=function(){this.values.forEach(function(t){return t.flattenOffset()})},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.addListener=function(t){var e=this,n=uniqueId(),i=function(n){n.value;return t(e.__getValue())};return this._listeners[n]=this.values.map(function(t){return t.addListener(i)}),n},n.removeListener=function(t){this.values.forEach(function(e){return e.removeListener(t)}),delete this._listeners[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),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),AnimatedTracking=function(t){function e(e,n,i,r,o){var a;return(a=t.call(this)||this)._value=e,a._parent=n,a._animationClass=i,a._animationConfig=r,a._callback=o,a.__attach(),a}_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};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(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,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),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 o=r.getInternalState();this._lastPosition=o.lastPosition,this._lastVelocity=o.lastVelocity,this._lastTime=o.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 o=Math.floor((r-this._lastTime)/1),a=0;a<o;++a){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*l/2),u=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*u/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*(c+p)+h)/6),e+=.001*((l+2*(u+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=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){var e=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){this.refName&&ApplyAnimatedValues.current(this.refName,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(){e.refName&&ApplyAnimatedValues.current(e.refName,e._propsAnimated.__getAnimatedValue(),e)||e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this,n=this._propsAnimated.__getValue();return React.createElement(t,_extends({},n,{ref:function(t){return e.refName=t}}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,o=e.toValue;return t instanceof AnimatedArray?parallel(t.values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:o[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),o={start:function(e){n!==t.length?t.forEach(function(a,s){var l=function(a){if(i[s]=!0,++n===t.length)return n=0,void(e&&e(a));!a.finished&&r&&o.stop()};a?a.start(l):l({finished:!0})}):e&&e({finished:!0})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return o},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)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.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("--"),o=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,o):n[i]=o}}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)}}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}),template=exports$2.template,animated=exports$2.elements,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,o=t.config,a=t.attach,s=t.immediate;void 0===e&&(e=!1);var l=Object.entries(_extends({},i,r)),c=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=l.reduce(function(t,r,l){var u,p=r[0],f=r[1],h=n.animations[p]||(n.animations[p]={}),d="number"==typeof f,_=!d&&Array.isArray(f),m=void 0!==i[p]?i[p]:f,v=d||_?f:1;if(d&&a){var y=a(n),g=y&&y.animations[p];g&&(v=g.animation)}if(d)h.animation=h.interpolation=h.animation||new exports$2.Value(m);else if(_)h.animation=h.interpolation=h.animation||new exports$2.Array(m);else{var A=h.interpolation&&h.interpolation._interpolation(c);h.animation=n.defaultAnimation,h.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==A?A:m,f]})}return!s||!0!==s&&-1===s.indexOf(p)||h.animation.setValue(v),h.start=function(){return exports$2.spring(h.animation,_extends({toValue:v},o)).start(0===l&&n.onRest)},h.stop=function(){return h.animation.stopAnimation()},e&&h.start(),n.interpolators[p]=h.interpolation,_extends({},t,((u={})[p]=h,u))},{});var u=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),u&&u.__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"]),o=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},o,r,{children:e})):e(_extends({},o,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1};var _initialiseProps=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}};"production"!==process.env.NODE_ENV&&(Spring.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])});var Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,o=e.keys,a=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(o)||(o=[o]),n.state={transitionsKeys:o,transitions:i.map(function(t,e){return{children:t,key:o[e],to:s,from:a}})},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,o=t.children,a=t.render,s=t.keys,l=t.from,c=t.enter,u=t.leave;o=a||o,Array.isArray(o)||(o=[o]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=o[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:o[e],key:t,to:c,from:l};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:u,from:l,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 _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,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,o=(e.keys,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,r=e.children,a=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(Spring,_extends({key:i},a,o,{render:r,children:t.props.children})):React.createElement(Spring,_extends({key:i},a,o,{children:r}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Transition.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=t.native,a=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),c=new Set,u=_extends({},l,{native:o,config:a,from:i,to:r});return(n||e).map(function(t,i){var r=function(t){return function(t,e){return c.add(e),0===t?void 0:Array.from(c)[t-1]}(i,t)};return n?React.createElement(Spring,_extends({key:s[i]},u,{attach:r,render:t,children:e})):React.createElement(Spring,_extends({key:s[i]},u,{attach:r,children:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Trail.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=e.className,a=e.scrolling,s=e.children,l=e.horizontal,c=a?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:a?this.scrollStop:null,onTouchStart:a?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:o},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,o=Math.floor(e.offset)*r.space,a=r.space*e.offset+o*e.speed,s=parseFloat(-r.current*e.speed+a);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,o=t*this.props.offset+r*this.props.speed,a=parseFloat(-e*this.props.speed+o);n?this.animatedTranslate.setValue(a):exports$2.spring(this.animatedTranslate,_extends({toValue:a},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),o=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),a=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:a?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},o,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[a?"height":"width"]="100%",t[a?"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.propTypes={factor:PropTypes.number,offset:PropTypes.number,speed:PropTypes.number},_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()}};"production"!==process.env.NODE_ENV&&(Parallax.propTypes={pages:PropTypes.number.isRequired,config:PropTypes.object,scrolling:PropTypes.bool,horizontal:PropTypes.bool});export{Spring,Transition,Trail,Parallax,config,template,animated}; | ||
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={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[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}(),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){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),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){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 o="extend";return void 0!==t.extrapolateRight?o=t.extrapolateRight:void 0!==t.extrapolate&&(o=t.extrapolate),function(t){var a=findRange(t,n);return interpolate(t,n[a],n[a+1],e[a],e[a+1],i,r,o)}},t}();function interpolate(t,e,n,i,r,o,a,s){var l=t;if(l<e){if("identity"===a)return l;"clamp"===a&&(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=o(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 _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},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}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},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,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},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._listeners={},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.setOffset=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setOffset(t)})},n.flattenOffset=function(){this.values.forEach(function(t){return t.flattenOffset()})},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.addListener=function(t){var e=this,n=uniqueId(),i=function(n){n.value;return t(e.__getValue())};return this._listeners[n]=this.values.map(function(t){return t.addListener(i)}),n},n.removeListener=function(t){this.values.forEach(function(e){return e.removeListener(t)}),delete this._listeners[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),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),AnimatedTracking=function(t){function e(e,n,i,r,o){var a;return(a=t.call(this)||this)._value=e,a._parent=n,a._animationClass=i,a._animationConfig=r,a._callback=o,a.__attach(),a}_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};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(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,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),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 o=r.getInternalState();this._lastPosition=o.lastPosition,this._lastVelocity=o.lastVelocity,this._lastTime=o.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 o=Math.floor((r-this._lastTime)/1),a=0;a<o;++a){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*l/2),u=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*u/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*(c+p)+h)/6),e+=.001*((l+2*(u+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=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}},refName="node";function createAnimatedComponent(t){var e=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){this.refName&&ApplyAnimatedValues.current(this.refName,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[refName],e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue();return React.createElement(t,_extends({},e,{ref:refName}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,o=e.toValue;return t instanceof AnimatedArray?parallel(t.values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:o[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),o={start:function(e){n!==t.length?t.forEach(function(a,s){var l=function(a){if(i[s]=!0,++n===t.length)return n=0,void(e&&e(a));!a.finished&&r&&o.stop()};a?a.start(l):l({finished:!0})}):e&&e({finished:!0})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return o},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)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.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("--"),o=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,o):n[i]=o}}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)}}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}),template=exports$2.template,animated=exports$2.elements,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,o=t.config,a=t.attach,s=t.immediate;void 0===e&&(e=!1);var l=Object.entries(_extends({},i,r)),c=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=l.reduce(function(t,r,l){var u,p=r[0],f=r[1],h=n.animations[p]||(n.animations[p]={}),d="number"==typeof f,_=!d&&Array.isArray(f),m=void 0!==i[p]?i[p]:f,v=d||_?f:1;if(d&&a){var y=a(n),g=y&&y.animations[p];g&&(v=g.animation)}if(d)h.animation=h.interpolation=h.animation||new exports$2.Value(m);else if(_)h.animation=h.interpolation=h.animation||new exports$2.Array(m);else{var A=h.interpolation&&h.interpolation._interpolation(c);h.animation=n.defaultAnimation,h.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==A?A:m,f]})}return!s||!0!==s&&-1===s.indexOf(p)||h.animation.setValue(v),h.start=function(){return exports$2.spring(h.animation,_extends({toValue:v},o)).start(0===l&&n.onRest)},h.stop=function(){return h.animation.stopAnimation()},e&&h.start(),n.interpolators[p]=h.interpolation,_extends({},t,((u={})[p]=h,u))},{});var u=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),u&&u.__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"]),o=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},o,r,{children:e})):e(_extends({},o,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1};var _initialiseProps=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}};"production"!==process.env.NODE_ENV&&(Spring.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])});var Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,o=e.keys,a=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(o)||(o=[o]),n.state={transitionsKeys:o,transitions:i.map(function(t,e){return{children:t,key:o[e],to:s,from:a}})},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,o=t.children,a=t.render,s=t.keys,l=t.from,c=t.enter,u=t.leave;o=a||o,Array.isArray(o)||(o=[o]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=o[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:o[e],key:t,to:c,from:l};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:u,from:l,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 _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,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,o=(e.keys,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,r=e.children,a=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(Spring,_extends({key:i},a,o,{render:r,children:t.props.children})):React.createElement(Spring,_extends({key:i},a,o,{children:r}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Transition.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=t.native,a=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),c=new Set,u=_extends({},l,{native:o,config:a,from:i,to:r});return(n||e).map(function(t,i){var r=function(t){return function(t,e){return c.add(e),0===t?void 0:Array.from(c)[t-1]}(i,t)};return n?React.createElement(Spring,_extends({key:s[i]},u,{attach:r,render:t,children:e})):React.createElement(Spring,_extends({key:s[i]},u,{attach:r,children:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Trail.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=e.className,a=e.scrolling,s=e.children,l=e.horizontal,c=a?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:a?this.scrollStop:null,onTouchStart:a?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:o},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,o=Math.floor(e.offset)*r.space,a=r.space*e.offset+o*e.speed,s=parseFloat(-r.current*e.speed+a);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,o=t*this.props.offset+r*this.props.speed,a=parseFloat(-e*this.props.speed+o);n?this.animatedTranslate.setValue(a):exports$2.spring(this.animatedTranslate,_extends({toValue:a},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),o=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),a=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:a?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},o,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[a?"height":"width"]="100%",t[a?"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.propTypes={factor:PropTypes.number,offset:PropTypes.number,speed:PropTypes.number},_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()}};"production"!==process.env.NODE_ENV&&(Parallax.propTypes={pages:PropTypes.number.isRequired,config:PropTypes.object,scrolling:PropTypes.bool,horizontal:PropTypes.bool});export{Spring,Transition,Trail,Parallax,config,template,animated}; |
@@ -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={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[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}(),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){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),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){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 o="extend";return void 0!==t.extrapolateRight?o=t.extrapolateRight:void 0!==t.extrapolate&&(o=t.extrapolate),function(t){var a=findRange(t,n);return interpolate(t,n[a],n[a+1],e[a],e[a+1],i,r,o)}},t}();function interpolate(t,e,n,i,r,o,a,s){var l=t;if(l<e){if("identity"===a)return l;"clamp"===a&&(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=o(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 _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},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}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},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,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},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._listeners={},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.setOffset=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setOffset(t)})},n.flattenOffset=function(){this.values.forEach(function(t){return t.flattenOffset()})},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.addListener=function(t){var e=this,n=uniqueId(),i=function(n){n.value;return t(e.__getValue())};return this._listeners[n]=this.values.map(function(t){return t.addListener(i)}),n},n.removeListener=function(t){this.values.forEach(function(e){return e.removeListener(t)}),delete this._listeners[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),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),AnimatedTracking=function(t){function e(e,n,i,r,o){var a;return(a=t.call(this)||this)._value=e,a._parent=n,a._animationClass=i,a._animationConfig=r,a._callback=o,a.__attach(),a}_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};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(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,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),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 o=r.getInternalState();this._lastPosition=o.lastPosition,this._lastVelocity=o.lastVelocity,this._lastTime=o.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 o=Math.floor((r-this._lastTime)/1),a=0;a<o;++a){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*l/2),u=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*u/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*(c+p)+h)/6),e+=.001*((l+2*(u+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=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){var e=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){this.refName&&ApplyAnimatedValues.current(this.refName,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(){e.refName&&ApplyAnimatedValues.current(e.refName,e._propsAnimated.__getAnimatedValue(),e)||e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this,n=this._propsAnimated.__getValue();return React.createElement(t,_extends({},n,{ref:function(t){return e.refName=t}}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,o=e.toValue;return t instanceof AnimatedArray?parallel(t.values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:o[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),o={start:function(e){n!==t.length?t.forEach(function(a,s){var l=function(a){if(i[s]=!0,++n===t.length)return n=0,void(e&&e(a));!a.finished&&r&&o.stop()};a?a.start(l):l({finished:!0})}):e&&e({finished:!0})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return o},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)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.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("--"),o=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,o):n[i]=o}}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)}}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}),template=exports$2.template,animated=exports$2.elements,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,o=t.config,a=t.attach,s=t.immediate;void 0===e&&(e=!1);var l=Object.entries(_extends({},i,r)),c=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=l.reduce(function(t,r,l){var u,p=r[0],f=r[1],h=n.animations[p]||(n.animations[p]={}),d="number"==typeof f,_=!d&&Array.isArray(f),m=void 0!==i[p]?i[p]:f,v=d||_?f:1;if(d&&a){var y=a(n),g=y&&y.animations[p];g&&(v=g.animation)}if(d)h.animation=h.interpolation=h.animation||new exports$2.Value(m);else if(_)h.animation=h.interpolation=h.animation||new exports$2.Array(m);else{var A=h.interpolation&&h.interpolation._interpolation(c);h.animation=n.defaultAnimation,h.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==A?A:m,f]})}return!s||!0!==s&&-1===s.indexOf(p)||h.animation.setValue(v),h.start=function(){return exports$2.spring(h.animation,_extends({toValue:v},o)).start(0===l&&n.onRest)},h.stop=function(){return h.animation.stopAnimation()},e&&h.start(),n.interpolators[p]=h.interpolation,_extends({},t,((u={})[p]=h,u))},{});var u=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),u&&u.__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"]),o=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},o,r,{children:e})):e(_extends({},o,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1};var _initialiseProps=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}};"production"!==process.env.NODE_ENV&&(Spring.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])});var Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,o=e.keys,a=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(o)||(o=[o]),n.state={transitionsKeys:o,transitions:i.map(function(t,e){return{children:t,key:o[e],to:s,from:a}})},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,o=t.children,a=t.render,s=t.keys,l=t.from,c=t.enter,u=t.leave;o=a||o,Array.isArray(o)||(o=[o]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=o[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:o[e],key:t,to:c,from:l};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:u,from:l,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 _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,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,o=(e.keys,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,r=e.children,a=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(Spring,_extends({key:i},a,o,{render:r,children:t.props.children})):React.createElement(Spring,_extends({key:i},a,o,{children:r}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Transition.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=t.native,a=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),c=new Set,u=_extends({},l,{native:o,config:a,from:i,to:r});return(n||e).map(function(t,i){var r=function(t){return function(t,e){return c.add(e),0===t?void 0:Array.from(c)[t-1]}(i,t)};return n?React.createElement(Spring,_extends({key:s[i]},u,{attach:r,render:t,children:e})):React.createElement(Spring,_extends({key:s[i]},u,{attach:r,children:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Trail.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=e.className,a=e.scrolling,s=e.children,l=e.horizontal,c=a?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:a?this.scrollStop:null,onTouchStart:a?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:o},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,o=Math.floor(e.offset)*r.space,a=r.space*e.offset+o*e.speed,s=parseFloat(-r.current*e.speed+a);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,o=t*this.props.offset+r*this.props.speed,a=parseFloat(-e*this.props.speed+o);n?this.animatedTranslate.setValue(a):exports$2.spring(this.animatedTranslate,_extends({toValue:a},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),o=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),a=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:a?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},o,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[a?"height":"width"]="100%",t[a?"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.propTypes={factor:PropTypes.number,offset:PropTypes.number,speed:PropTypes.number},_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()}};"production"!==process.env.NODE_ENV&&(Parallax.propTypes={pages:PropTypes.number.isRequired,config:PropTypes.object,scrolling:PropTypes.bool,horizontal:PropTypes.bool}),exports.Spring=Spring,exports.Transition=Transition,exports.Trail=Trail,exports.Parallax=Parallax,exports.config=config,exports.template=template,exports.animated=animated; | ||
"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={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[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}(),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){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),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){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 o="extend";return void 0!==t.extrapolateRight?o=t.extrapolateRight:void 0!==t.extrapolate&&(o=t.extrapolate),function(t){var a=findRange(t,n);return interpolate(t,n[a],n[a+1],e[a],e[a+1],i,r,o)}},t}();function interpolate(t,e,n,i,r,o,a,s){var l=t;if(l<e){if("identity"===a)return l;"clamp"===a&&(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=o(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 _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},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}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},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,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},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._listeners={},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.setOffset=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setOffset(t)})},n.flattenOffset=function(){this.values.forEach(function(t){return t.flattenOffset()})},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.addListener=function(t){var e=this,n=uniqueId(),i=function(n){n.value;return t(e.__getValue())};return this._listeners[n]=this.values.map(function(t){return t.addListener(i)}),n},n.removeListener=function(t){this.values.forEach(function(e){return e.removeListener(t)}),delete this._listeners[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),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),AnimatedTracking=function(t){function e(e,n,i,r,o){var a;return(a=t.call(this)||this)._value=e,a._parent=n,a._animationClass=i,a._animationConfig=r,a._callback=o,a.__attach(),a}_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};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(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,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),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 o=r.getInternalState();this._lastPosition=o.lastPosition,this._lastVelocity=o.lastVelocity,this._lastTime=o.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 o=Math.floor((r-this._lastTime)/1),a=0;a<o;++a){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*l/2),u=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*u/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*(c+p)+h)/6),e+=.001*((l+2*(u+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=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}},refName="node";function createAnimatedComponent(t){var e=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){this.refName&&ApplyAnimatedValues.current(this.refName,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[refName],e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue();return React.createElement(t,_extends({},e,{ref:refName}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,o=e.toValue;return t instanceof AnimatedArray?parallel(t.values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:o[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),o={start:function(e){n!==t.length?t.forEach(function(a,s){var l=function(a){if(i[s]=!0,++n===t.length)return n=0,void(e&&e(a));!a.finished&&r&&o.stop()};a?a.start(l):l({finished:!0})}):e&&e({finished:!0})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return o},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)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.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("--"),o=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,o):n[i]=o}}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)}}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}),template=exports$2.template,animated=exports$2.elements,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,o=t.config,a=t.attach,s=t.immediate;void 0===e&&(e=!1);var l=Object.entries(_extends({},i,r)),c=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=l.reduce(function(t,r,l){var u,p=r[0],f=r[1],h=n.animations[p]||(n.animations[p]={}),d="number"==typeof f,_=!d&&Array.isArray(f),m=void 0!==i[p]?i[p]:f,v=d||_?f:1;if(d&&a){var y=a(n),g=y&&y.animations[p];g&&(v=g.animation)}if(d)h.animation=h.interpolation=h.animation||new exports$2.Value(m);else if(_)h.animation=h.interpolation=h.animation||new exports$2.Array(m);else{var A=h.interpolation&&h.interpolation._interpolation(c);h.animation=n.defaultAnimation,h.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==A?A:m,f]})}return!s||!0!==s&&-1===s.indexOf(p)||h.animation.setValue(v),h.start=function(){return exports$2.spring(h.animation,_extends({toValue:v},o)).start(0===l&&n.onRest)},h.stop=function(){return h.animation.stopAnimation()},e&&h.start(),n.interpolators[p]=h.interpolation,_extends({},t,((u={})[p]=h,u))},{});var u=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),u&&u.__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"]),o=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},o,r,{children:e})):e(_extends({},o,r))},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1};var _initialiseProps=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}};"production"!==process.env.NODE_ENV&&(Spring.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])});var Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,o=e.keys,a=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(o)||(o=[o]),n.state={transitionsKeys:o,transitions:i.map(function(t,e){return{children:t,key:o[e],to:s,from:a}})},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,o=t.children,a=t.render,s=t.keys,l=t.from,c=t.enter,u=t.leave;o=a||o,Array.isArray(o)||(o=[o]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=o[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:o[e],key:t,to:c,from:l};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:u,from:l,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 _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,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,o=(e.keys,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,r=e.children,a=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(Spring,_extends({key:i},a,o,{render:r,children:t.props.children})):React.createElement(Spring,_extends({key:i},a,o,{children:r}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Transition.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=t.native,a=t.config,s=t.keys,l=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),c=new Set,u=_extends({},l,{native:o,config:a,from:i,to:r});return(n||e).map(function(t,i){var r=function(t){return function(t,e){return c.add(e),0===t?void 0:Array.from(c)[t-1]}(i,t)};return n?React.createElement(Spring,_extends({key:s[i]},u,{attach:r,render:t,children:e})):React.createElement(Spring,_extends({key:s[i]},u,{attach:r,children:t}))})},e}(React.PureComponent);Trail.defaultProps={from:{},to:{},native:!1,config:config.default},"production"!==process.env.NODE_ENV&&(Trail.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])});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,o=e.className,a=e.scrolling,s=e.children,l=e.horizontal,c=a?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:a?this.scrollStop:null,onTouchStart:a?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:o},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,o=Math.floor(e.offset)*r.space,a=r.space*e.offset+o*e.speed,s=parseFloat(-r.current*e.speed+a);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,o=t*this.props.offset+r*this.props.speed,a=parseFloat(-e*this.props.speed+o);n?this.animatedTranslate.setValue(a):exports$2.spring(this.animatedTranslate,_extends({toValue:a},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),o=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),a=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:a?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},o,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[a?"height":"width"]="100%",t[a?"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.propTypes={factor:PropTypes.number,offset:PropTypes.number,speed:PropTypes.number},_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()}};"production"!==process.env.NODE_ENV&&(Parallax.propTypes={pages:PropTypes.number.isRequired,config:PropTypes.object,scrolling:PropTypes.bool,horizontal:PropTypes.bool}),exports.Spring=Spring,exports.Transition=Transition,exports.Trail=Trail,exports.Parallax=Parallax,exports.config=config,exports.template=template,exports.animated=animated; |
{ | ||
"name": "react-spring", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Animate React with ease", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-spring", |
@@ -7,3 +7,3 @@ [![Build Status](https://travis-ci.org/drcmda/react-spring.svg?branch=master)](https://travis-ci.org/drcmda/react-spring) [![npm version](https://badge.fury.io/js/react-spring.svg)](https://badge.fury.io/js/react-spring) | ||
React-spring is a wrapper around a cooked down fork of [Facebooks animated](http://animatedjs.github.io/interactive-docs/). It is trying to cross it with Chenglou's [React-motion](https://github.com/chenglou/react-motion). Both have their pros and cons and could benefit from one another: | ||
React-spring is a cooked down fork of [Facebooks animated](http://animatedjs.github.io/interactive-docs/). It is trying to bridge it with Chenglou's [React-motion](https://github.com/chenglou/react-motion) because both have their pros and cons but could definitively benefit from one another: | ||
@@ -28,2 +28,15 @@ #### React-motion | ||
<p align="middle"> | ||
<img src="assets/spring.gif" width="430" /> | ||
<img src="assets/transition.gif" width="430" /> | ||
</p> | ||
<p align="middle"> | ||
<img src="assets/reveal.gif" width="430" /> | ||
<img src="assets/trail.gif" width="430" /> | ||
</p> | ||
<p align="middle"> | ||
<img src="assets/scroll.gif" width="430" height="222.88" /> | ||
<img src="assets/parallax.gif" width="430" /> | ||
</p> | ||
```jsx | ||
@@ -33,12 +46,8 @@ import { Spring, Transition, Trail, Parallax } from 'react-spring' | ||
### Springs ([Demo](https://codesandbox.io/embed/oln44nx8xq)) | ||
#### Springs ([Demo](https://codesandbox.io/embed/oln44nx8xq)) | ||
<p align="center"> | ||
<img src="assets/spring.gif"/> | ||
</p> | ||
A `Spring` will move data from one state to another. It remembers the current state, value changes are always fluid. | ||
```jsx | ||
<Spring | ||
from={{ opacity: 0 }} | ||
to={{ opacity: 1 }}> | ||
<Spring from={{ opacity: 0 }} to={{ opacity: 1 }}> | ||
{styles => <div style={styles}>i will fade in</div>} | ||
@@ -48,7 +57,5 @@ </Spring> | ||
### Mount/unmount transitions ([Demo](https://codesandbox.io/embed/j150ykxrv)) | ||
#### Mount/unmount Transitions ([Demo](https://codesandbox.io/embed/j150ykxrv)) | ||
<p align="center"> | ||
<img src="assets/transition.gif"/> | ||
</p> | ||
`Transition` watches elements as they mount and unmount, it helps you to animate these changes. | ||
@@ -58,5 +65,5 @@ ```jsx | ||
keys={items.map(item => item.key)} | ||
from={{ opacity: 0 }} | ||
enter={{ opacity: 1 }} | ||
leave={{ opacity: 0 }}> | ||
from={{ opacity: 0, height: 0 }} | ||
enter={{ opacity: 1, height: 20 }} | ||
leave={{ opacity: 0, height: 0 }}> | ||
{items.map(item => styles => <li style={styles}>{item.text}</li>)} | ||
@@ -66,11 +73,9 @@ </Transition> | ||
### Reveals ([Demo](https://codesandbox.io/embed/882njxpz29)) | ||
#### 2-state Reveals ([Demo](https://codesandbox.io/embed/yj52v5689)) | ||
<p align="center"> | ||
<img src="assets/reveal.gif"/> | ||
</p> | ||
Given a single child instead of a list you can reveal components with it. | ||
```jsx | ||
<Transition | ||
keys={toggle ? 'ComponentA' : 'ComponentB'} | ||
keys={toggle ? 'A' : 'B'} | ||
from={{ opacity: 0 }} | ||
@@ -83,13 +88,8 @@ enter={{ opacity: 1 }} | ||
### Trails/staggered animations ([Demo](https://codesandbox.io/embed/vvmv6x01l5)) | ||
#### Trails and staggered animations ([Demo](https://codesandbox.io/embed/vvmv6x01l5)) | ||
<p align="center"> | ||
<img src="assets/trail.gif"/> | ||
</p> | ||
`Trail` animates the first child of a list of elements, the rest follow the spring of their previous sibling. | ||
```jsx | ||
<Trail | ||
from={{ opacity: 0 }} | ||
to={{ opacity: 1 }} | ||
keys={items.map(item => item.key)}> | ||
<Trail from={{ opacity: 0 }} to={{ opacity: 1 }} keys={items.map(item => item.key)}> | ||
{items.map(item => styles => <div style={styles}>{item.text}</div>)} | ||
@@ -99,7 +99,5 @@ </Trail> | ||
### Parallax & page transitions ([Demo](https://codesandbox.io/embed/548lqnmk6l)) | ||
#### Parallax and page transitions ([Demo](https://codesandbox.io/embed/548lqnmk6l)) | ||
<p align="center"> | ||
<img src="assets/parallax.gif"/> | ||
</p> | ||
`Parallax` allows you to declaratively create page/scroll-based animations. | ||
@@ -113,8 +111,10 @@ ```jsx | ||
### Additional demos: [TodoMVC](https://codesandbox.io/embed/2pk8l7n7kn) | [DragList](https://codesandbox.io/embed/l9zqz0m18z) | [Graphs](https://codesandbox.io/embed/j3x61vjz5v) | ||
#### Additional demos: [Vertical scroll](https://codesandbox.io/embed/0oonqxnpjl) | [Animated graphs](https://codesandbox.io/embed/j3x61vjz5v) | [Animated todoMVC](https://codesandbox.io/embed/2pk8l7n7kn) | [Drag n drop](https://codesandbox.io/embed/l9zqz0m18z) | ||
# API | ||
# API overview 📖 | ||
## Springs and default rendering | ||
For a raw documentation of all possible properties look [here](https://github.com/drcmda/react-spring/blob/master/API.md). | ||
### Springs and interpolation | ||
You can interpolate almost everything, from numbers, colors, svg-paths, percentages, arrays to string patterns: | ||
@@ -132,2 +132,4 @@ | ||
### Render props | ||
Don't like the way render props wrap your code? | ||
@@ -149,10 +151,8 @@ | ||
Et voilà! Now you render a animated version of the `Header` component! All props that `Spring` doesn't recognize as its own will be spread over the receiving component, including `children` if you use `render` instead. It's actually faster as well since the function isn't recreated on every prop-change. | ||
Et voilà! `Header` animates on prop changes! Props that `Spring` doesn't recognize will be spread over the receiving component, including `children` if you use `render` to refer to the render-child. | ||
## Native rendering ([Demo](https://codesandbox.io/embed/882njxpz29)) | ||
### Native rendering ([Demo](https://codesandbox.io/embed/882njxpz29)) | ||
Like React-motion by default we'll render the receiving component every frame as it gives you more freedom to animate whatever you like. That means you can animate dom styles & props, but also any React component. In some situations this can be expensive. | ||
By default we'll render the receiving component every frame as it gives you more freedom to animate. In situations where that becomes expensive add the `native` flag and animations will now be applied directly to the dom. The flag is available for all primitives (Spring, Transition & Trail, Parallax is native by design). | ||
Pass the `native` flag and the animations will now be applied *directly* to the dom through requestAnimationFrame. The component will only re-render when it receives new props. The flag is available for all primitives (Spring, Transition & Trail, Parallax is native by design). | ||
Just be aware of the following conditions: | ||
@@ -176,5 +176,5 @@ | ||
## Transitions | ||
### Transitions | ||
Use `Transition` and pass in your `keys`. `from` denotes base styles, `enter` styles are applied when objects appear, `leave` styles are applied when objects disappear. Keys and children have to match in their order! | ||
Animates children as they mount and unmount. `from` denotes base styles, `enter` styles are applied when objects appear, `leave` styles are applied when objects disappear. Keys and children have to match in their order! The keys are the same that you would provide in any other looping situation. | ||
@@ -207,5 +207,5 @@ ```jsx | ||
## Trails/Staggered transitions | ||
### Trails/Staggered transitions | ||
Create trailing animations by using `Trail`. The api is similar to `Transition` though it will assume your list is fixed. The items will interpolate in a staggered fashion, internally one spring follows the interpolated value of the previous one thereby creating a staggered chain. | ||
`Trail` animates the first child of the list you pass, the others will follow in a trailing motion. The api is similar to `Transition` though it will assume your list is fixed. | ||
@@ -220,7 +220,7 @@ ```jsx | ||
## Parallax and page transitions | ||
### Parallax and page transitions | ||
`Parallax` creates a scroll container. Throw in any amount of layers and it will take care of moving them in accordance to their offsets and scrolling speeds. This makes complex page transitions as effortless as it gets. | ||
`Parallax` creates a scroll container. Throw in any amount of layers and it will take care of moving them in accordance to their offsets and speeds. | ||
`Parallax.pages` determines the total height/width of the inner content where each page takes 100% height of the visible container. `Layer.offset` determines where the layer will be at when scrolled to (0=start, 1=1st page, and so on ...). `Layer.speed` allows for positive and negative values, it shifts the layer in accordance to its offset. | ||
`Parallax.pages` determines the total space of the inner content where each page takes 100% of the visible container. `Layer.offset` determines where the layer will be at when scrolled to (0=start, 1=1st page, ...). `Layer.speed` shifts the layer in accordance to its offset, values can be positive or negative. | ||
@@ -232,3 +232,3 @@ ```jsx | ||
<Parallax.Layer offset={0} speed={0.5}> | ||
<span onClick={() => this.parallax.scrollTo(1)}>> | ||
<span onClick={() => this.parallax.scrollTo(1)}> | ||
Layers can contain anything | ||
@@ -235,0 +235,0 @@ </span> |
@@ -5,2 +5,4 @@ import React from 'react' | ||
const refName = 'node' | ||
function createAnimatedComponent(Component) { | ||
@@ -31,7 +33,6 @@ class AnimatedComponent extends React.Component { | ||
var callback = () => { | ||
var didUpdate = | ||
this.refName && | ||
ApplyAnimatedValues.current(this.refName, this._propsAnimated.__getAnimatedValue(), this) | ||
if (!didUpdate) this.forceUpdate() | ||
var didUpdate = ApplyAnimatedValues.current(this.refs[refName], this._propsAnimated.__getAnimatedValue(), this) | ||
if (didUpdate === false) { | ||
this.forceUpdate() | ||
} | ||
} | ||
@@ -58,3 +59,3 @@ | ||
const styles = this._propsAnimated.__getValue() | ||
return <Component {...styles} ref={ref => (this.refName = ref)} /> | ||
return <Component {...styles} ref={refName} /> | ||
} | ||
@@ -61,0 +62,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
213344
1961