react-spring
Advanced tools
Comparing version 4.0.4 to 4.0.5
@@ -1,1 +0,1 @@ | ||
import normalizeColor from"normalize-css-color";import React from"react";import PropTypes from"prop-types";function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o._hey=1,o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){t instanceof AnimatedTracking&&(this._tracked=!0),0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(AnimatedWithChildren),_uniqueId=0;function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){(0===this._animatedStyles.size||this._tracked)&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){for(var e in this._value=t,this._flush(),this._listeners)this._listeners[e]({value:this.__getValue()})},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.addListener=function(t){var e=String(_uniqueId++);return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new AnimatedValue(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),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}(),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var a=Math.floor((r-this._lastTime)/1),o=0;o<a;++o){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,u=(n=t+.001*s/2,i=e+.001*l/2),c=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*u/2;var p=i=e+.001*c/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(u+p)+h)/6),e+=.001*((l+2*(c+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var m=!1;this._overshootClamping&&0!==this._tension&&(m=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var _=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),m||_&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof AnimatedArray?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return(n=t.call(this)||this).callback=function(t){n.props.onFrame&&n.props.onFrame(n.propsAnimated.__getValue()),!n.props.native&&n.forceUpdate()},n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n.update=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset,u=(t.onFrame,t.onRest);void 0===e&&(e=!1);var c=Object.entries(_extends({},i,r)),p=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(t,e,r){var c,f=e[0],h=e[1],d=!1===l&&n.animations[f]||(n.animations[f]={}),m="number"==typeof h,_=!m&&Array.isArray(h),v=void 0!==i[f]?i[f]:h,g=m||_?h:1;if(m&&o){var y=o(n),A=y&&y.animations[f];A&&(g=A.animation)}if(m)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(_)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(p);d.animation=n.defaultAnimation,d.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,h]})}return!s||!0!==s&&-1===s.indexOf(f)||d.animation.setValue(g),d.stopped=!1,d.start=function(){exports$2.spring(d.animation,_extends({toValue:g},a)).start(function(t){t.finished&&(n.animations[f].stopped=!0,Object.values(n.animations).every(function(t){return t.stopped})&&u&&u(_extends({},n.props.from,n.props.to)))})},d.stop=function(){return d.animation.stopAnimation()},n.interpolators[f]=d.interpolation,_extends({},t,((c={})[f]=d,c))},{});var f=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),f&&f.__detach(),e&&Object.values(this.animations).forEach(function(t){return t.start()})},n.componentWillReceiveProps=function(t){this.update(t,!0)},n.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return t.start()})},n.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return t.stop()})},n.getValues=function(){return this.propsAnimated.__getValue()},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=_extends({},i?this.interpolators:this.propsAnimated.__getValue(),r);return n?n(_extends({},a,{children:e})):Array.isArray(e)?e.map(function(t){return t(a)}):e(a)},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1};var ref=function(t,e){return"function"==typeof t?t(e):t},Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.items,s=e.from,l=e.enter,u=(e.leave,e.update);return i=r||i||function(){return null},"function"==typeof a&&(a=o.map(a)),Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionKeys:a,transitions:i.map(function(t,e){var n=o?o[e]:a[e];return{children:t,key:a[e],item:n,to:ref(l,n),from:ref(s,n),update:ref(u,n)}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionKeys,a=t.children,o=t.render,s=t.keys,l=t.items,u=t.from,c=t.enter,p=t.leave,f=t.update;a=o||a||function(){return null},"function"==typeof s&&(s=l.map(s)),Array.isArray(a)||(a=[a],s=s?[s]:a);var h=new Set(s),d=new Set(r),m=s.filter(function(t){return!d.has(t)}),_=r.filter(function(t){return!h.has(t)}),v=s.filter(function(t){return d.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n),f&&-1!==v.indexOf(t.key)&&(t.to=ref(f,l?l[e]:s[e])||t.to)}return t}),m.length&&m.forEach(function(t){var e=s.indexOf(t),n=a[e],r=l?l[e]:s[e],o={children:n,key:s[e],item:r,to:ref(c,r),from:ref(u,r)};i=i.slice(0,e).concat([o],i.slice(e))}),_.length&&_.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:ref(p,n.item),from:ref(u,n.item),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var g=s.map(function(t){return i.find(function(e){return e.key===t})});i.forEach(function(t,e){t.destroy&&!g.find(function(e){return e.key===t.key})&&(g=g.slice(0,e).concat([t],g.slice(e)))}),this.setState({transitions:g,transitionKeys:r})},n.getValues=function(){},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.items,e.onFrame),o=(e.onRest,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","items","onFrame","onRest"])));return this.state.transitions.map(function(e,i){var r=e.key,s=e.item,l=e.children,u=_objectWithoutProperties(e,["key","item","children"]);return React.createElement(Spring,_extends({key:r},u,o,{onFrame:a&&function(t){return a(s,t)},render:n&&l,children:n?t.props.children:l}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default};var _class,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose(e,t);var n=e.prototype;return n.getValues=function(){return this.instance&&this.instance.getValues()},n.render=function(){var t=this,e=this.props,n=e.children,i=e.render,r=e.from,a=e.to,o=e.native,s=e.config,l=e.keys,u=e.onRest,c=_objectWithoutProperties(e,["children","render","from","to","native","config","keys","onRest"]),p=new Set,f=_extends({},c,{native:o,config:s,from:r,to:a});return(i||n).map(function(e,r){return React.createElement(Spring,_extends({ref:function(e){return 0===r&&(t.instance=e)},onRest:0===r?u:null,key:l[r]},f,{attach:function(t){return function(t,e){return p.add(e),0===t?void 0:Array.from(p)[t-1]}(r,t)},render:i&&e,children:i?n:e}))})},e}(React.PureComponent);function getScrollType(t){return t?"scrollLeft":"scrollTop"}Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps.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,r=getScrollType(n);this.scrollStop(),this.offset=t;var a=this.refs.container;this.animatedScroll=new exports$2.Value(a[r]),this.animatedScroll.addListener(function(t){var e=t.value;return a[r]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,u=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:u,overflowY:l?"hidden":u,overflowX:l?u:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class.contextTypes={parallax:PropTypes.object},_class.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps=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[getScrollType(n)])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal,r=getScrollType(i);t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[r]:t.refs.container[r]=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()}},Keyframes=function(t){function e(){for(var e,n,i=arguments.length,r=new Array(i),a=0;a<i;a++)r[a]=arguments[a];return e=n=t.call.apply(t,[this].concat(r))||this,n.state={primitive:void 0,props:{},resolve:function(){return null}},n.next=function(t,e){return new Promise(function(i){var r=n.instance&&n.instance.getValues(),a="function"==typeof e.from?e.from:_extends({},n.state.props.from,r,e.from);n.setState(function(n){return{primitive:t,props:_extends({},e,{from:a}),resolve:i}})})},e||_assertThisInitialized(n)}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){this.props.script&&this.props.script(this.next)},n.render=function(){var t=this,e=this.state,n=e.primitive,i=e.props,r=e.resolve,a=this.props,o=(a.script,_objectWithoutProperties(a,["script"]));return n?React.createElement(n,_extends({ref:function(e){return t.instance=e}},o,i,{onRest:r})):null},e}(React.Component);export{Spring,Keyframes,Transition,Trail,Parallax,config,template,animated,interpolate$1 as interpolate}; | ||
import normalizeColor from"normalize-css-color";import React from"react";import PropTypes from"prop-types";function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o._hey=1,o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){t instanceof AnimatedTracking&&(this._tracked=!0),0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(AnimatedWithChildren),_uniqueId=0;function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){(0===this._animatedStyles.size||this._tracked)&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){for(var e in this._value=t,this._flush(),this._listeners)this._listeners[e]({value:this.__getValue()})},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.addListener=function(t){var e=String(_uniqueId++);return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new AnimatedValue(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),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}(),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var a=Math.floor((r-this._lastTime)/1),o=0;o<a;++o){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,u=(n=t+.001*s/2,i=e+.001*l/2),c=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*u/2;var p=i=e+.001*c/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(u+p)+h)/6),e+=.001*((l+2*(c+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!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){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof AnimatedArray?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return(n=t.call(this)||this).callback=function(){n.props.onFrame&&n.props.onFrame(n._propsAnimated.__getValue()),!n.props.native&&n.forceUpdate()},n._defaultAnimation=new exports$2.Value(0),n._animations={},n._updateProps(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n._updateProps=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset,u=t.delay,c=(t.onFrame,t.onRest);void 0===e&&(e=!1);var p=Object.entries(_extends({},i,r)),f=this._defaultAnimation._value;this._interpolators={},this._defaultAnimation.setValue(0),this._animations=p.reduce(function(t,e,r){var u,p=e[0],h=e[1],d=!1===l&&n._animations[p]||(n._animations[p]={}),_="number"==typeof h,m=!_&&Array.isArray(h),v=void 0!==i[p]?i[p]:h,y=_||m?h:1;if(_&&o){var g=o(n),A=g&&g._animations[p];A&&(y=A.animation)}if(_)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(m)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(f);d.animation=n._defaultAnimation,d.interpolation=n._defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,h]})}return!s||!0!==s&&-1===s.indexOf(p)||d.animation.setValue(y),d.stopped=!1,d.start=function(){exports$2.spring(d.animation,_extends({toValue:y},a)).start(function(t){t.finished&&(n._animations[p].stopped=!0,Object.values(n._animations).every(function(t){return t.stopped})&&c&&c(_extends({},n.props.from,n.props.to)))})},d.stop=function(){return d.animation.stopAnimation()},n._interpolators[p]=d.interpolation,_extends({},t,((u={})[p]=d,u))},{}),e&&this.start({delay:u});var h=this._propsAnimated;this._propsAnimated=new exports$2.AnimatedProps(this._interpolators,this.callback),h&&h.__detach()},n.start=function(t){var e=this;return void 0===t&&(t=this.props),new Promise(function(n){var i=function(){Object.values(e._animations).forEach(function(t){return t.start()}),e._delay=void 0};t.delay>0?(e._delay&&clearTimeout(e._delay),e._delay=setTimeout(i,t.delay)):i()})},n.stop=function(){this._delay&&(clearTimeout(this._delay),this._delay=void 0),Object.values(this._animations).forEach(function(t){return t.stop()})},n.update=function(t){this._updateProps(_extends({},this.props,t),!0)},n.componentWillReceiveProps=function(t){this._updateProps(t,!0)},n.componentDidMount=function(){this.start()},n.componentWillUnmount=function(){this.stop()},n.getValues=function(){return this._propsAnimated.__getValue()},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=_extends({},i?this._interpolators:this._propsAnimated.__getValue(),r);return n?n(_extends({},a,{children:e})):Array.isArray(e)?e.map(function(t){return t(a)}):e(a)},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1,delay:0};var ref=function(t,e){return"function"==typeof t?t(e):t};function shallowDiffers(t,e){for(var n in t)if(!(n in e))return!0;for(var i in e)if(t[i]!==e[i])return!0;return!1}var Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.items,s=e.from,l=e.enter,u=(e.leave,e.update);return i=r||i||function(){return null},"function"==typeof a&&(a=o.map(a)),Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionKeys:a,transitions:i.map(function(t,e){var n=o?o[e]:a[e];return{children:t,key:a[e],item:n,to:ref(l,n),from:ref(s,n),update:ref(u,n)}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.shouldComponentUpdate=function(t){return shallowDiffers(t,this.props)},n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionKeys,a=t.children,o=t.render,s=t.keys,l=t.items,u=t.from,c=t.enter,p=t.leave,f=t.update;a=o||a||function(){return null},"function"==typeof s&&(s=l.map(s)),Array.isArray(a)||(a=[a],s=s?[s]:a);var h=new Set(s),d=new Set(r),_=s.filter(function(t){return!d.has(t)}),m=r.filter(function(t){return!h.has(t)}),v=s.filter(function(t){return d.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n),f&&-1!==v.indexOf(t.key)&&(t.to=ref(f,l?l[e]:s[e])||t.to)}return t}),_.length&&_.forEach(function(t){var e=s.indexOf(t),n=a[e],r=l?l[e]:s[e],o={children:n,key:s[e],item:r,to:ref(c,r),from:ref(u,r)};i=i.slice(0,e).concat([o],i.slice(e))}),m.length&&m.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:ref(p,n.item),from:ref(u,n.item),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var y=s.map(function(t){return i.find(function(e){return e.key===t})});i.forEach(function(t,e){t.destroy&&!y.find(function(e){return e.key===t.key})&&(y=y.slice(0,e).concat([t],y.slice(e)))}),this.setState({transitions:y,transitionKeys:r})},n.getValues=function(){},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.items,e.onFrame),o=(e.onRest,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","items","onFrame","onRest"])));return this.state.transitions.map(function(e,i){var r=e.key,s=e.item,l=e.children,u=_objectWithoutProperties(e,["key","item","children"]);return React.createElement(Spring,_extends({key:r},u,o,{onFrame:a&&function(t){return a(s,t)},render:n&&l,children:n?t.props.children:l}))})},e}(React.Component);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default};var _class,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose(e,t);var n=e.prototype;return n.getValues=function(){return this.instance&&this.instance.getValues()},n.render=function(){var t=this,e=this.props,n=e.children,i=e.render,r=e.from,a=e.to,o=e.native,s=e.config,l=e.keys,u=e.onRest,c=_objectWithoutProperties(e,["children","render","from","to","native","config","keys","onRest"]),p=new Set,f=_extends({},c,{native:o,config:s,from:r,to:a});return(i||n).map(function(e,r){return React.createElement(Spring,_extends({ref:function(e){return 0===r&&(t.instance=e)},onRest:0===r?u:null,key:l[r]},f,{attach:function(t){return function(t,e){return p.add(e),0===t?void 0:Array.from(p)[t-1]}(r,t)},render:i&&e,children:i?n:e}))})},e}(React.PureComponent);function getScrollType(t){return t?"scrollLeft":"scrollTop"}Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps.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,r=getScrollType(n);this.scrollStop(),this.offset=t;var a=this.refs.container;this.animatedScroll=new exports$2.Value(a[r]),this.animatedScroll.addListener(function(t){var e=t.value;return a[r]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,u=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:u,overflowY:l?"hidden":u,overflowX:l?u:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class.contextTypes={parallax:PropTypes.object},_class.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps=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[getScrollType(n)])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal,r=getScrollType(i);t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[r]:t.refs.container[r]=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()}},Keyframes=function(t){function e(){for(var e,n,i=arguments.length,r=new Array(i),a=0;a<i;a++)r[a]=arguments[a];return e=n=t.call.apply(t,[this].concat(r))||this,n.state={primitive:void 0,props:{},resolve:function(){return null}},n.next=function(t,e){return new Promise(function(i){var r=n.instance&&n.instance.getValues(),a="function"==typeof e.from?e.from:_extends({},n.state.props.from,r,e.from);n.setState(function(n){return{primitive:t,props:_extends({},e,{from:a}),resolve:i}})})},e||_assertThisInitialized(n)}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){this.props.script&&this.props.script(this.next)},n.render=function(){var t=this,e=this.state,n=e.primitive,i=e.props,r=e.resolve,a=this.props,o=(a.script,_objectWithoutProperties(a,["script"]));return n?React.createElement(n,_extends({ref:function(e){return t.instance=e}},o,i,{onRest:r})):null},e}(React.Component);export{Spring,Keyframes,Transition,Trail,Parallax,config,template,animated,interpolate$1 as interpolate}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var normalizeColor=_interopDefault(require("normalize-css-color")),React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types"));function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o._hey=1,o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){t instanceof AnimatedTracking&&(this._tracked=!0),0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(AnimatedWithChildren),_uniqueId=0;function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){(0===this._animatedStyles.size||this._tracked)&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){for(var e in this._value=t,this._flush(),this._listeners)this._listeners[e]({value:this.__getValue()})},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.addListener=function(t){var e=String(_uniqueId++);return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new AnimatedValue(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),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}(),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var a=Math.floor((r-this._lastTime)/1),o=0;o<a;++o){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,u=(n=t+.001*s/2,i=e+.001*l/2),c=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*u/2;var p=i=e+.001*c/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(u+p)+h)/6),e+=.001*((l+2*(c+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var m=!1;this._overshootClamping&&0!==this._tension&&(m=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var _=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),m||_&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof AnimatedArray?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return(n=t.call(this)||this).callback=function(t){n.props.onFrame&&n.props.onFrame(n.propsAnimated.__getValue()),!n.props.native&&n.forceUpdate()},n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n.update=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset,u=(t.onFrame,t.onRest);void 0===e&&(e=!1);var c=Object.entries(_extends({},i,r)),p=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(t,e,r){var c,f=e[0],h=e[1],d=!1===l&&n.animations[f]||(n.animations[f]={}),m="number"==typeof h,_=!m&&Array.isArray(h),v=void 0!==i[f]?i[f]:h,g=m||_?h:1;if(m&&o){var y=o(n),A=y&&y.animations[f];A&&(g=A.animation)}if(m)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(_)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(p);d.animation=n.defaultAnimation,d.interpolation=n.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,h]})}return!s||!0!==s&&-1===s.indexOf(f)||d.animation.setValue(g),d.stopped=!1,d.start=function(){exports$2.spring(d.animation,_extends({toValue:g},a)).start(function(t){t.finished&&(n.animations[f].stopped=!0,Object.values(n.animations).every(function(t){return t.stopped})&&u&&u(_extends({},n.props.from,n.props.to)))})},d.stop=function(){return d.animation.stopAnimation()},n.interpolators[f]=d.interpolation,_extends({},t,((c={})[f]=d,c))},{});var f=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),f&&f.__detach(),e&&Object.values(this.animations).forEach(function(t){return t.start()})},n.componentWillReceiveProps=function(t){this.update(t,!0)},n.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return t.start()})},n.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return t.stop()})},n.getValues=function(){return this.propsAnimated.__getValue()},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=_extends({},i?this.interpolators:this.propsAnimated.__getValue(),r);return n?n(_extends({},a,{children:e})):Array.isArray(e)?e.map(function(t){return t(a)}):e(a)},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1};var ref=function(t,e){return"function"==typeof t?t(e):t},Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.items,s=e.from,l=e.enter,u=(e.leave,e.update);return i=r||i||function(){return null},"function"==typeof a&&(a=o.map(a)),Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionKeys:a,transitions:i.map(function(t,e){var n=o?o[e]:a[e];return{children:t,key:a[e],item:n,to:ref(l,n),from:ref(s,n),update:ref(u,n)}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionKeys,a=t.children,o=t.render,s=t.keys,l=t.items,u=t.from,c=t.enter,p=t.leave,f=t.update;a=o||a||function(){return null},"function"==typeof s&&(s=l.map(s)),Array.isArray(a)||(a=[a],s=s?[s]:a);var h=new Set(s),d=new Set(r),m=s.filter(function(t){return!d.has(t)}),_=r.filter(function(t){return!h.has(t)}),v=s.filter(function(t){return d.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n),f&&-1!==v.indexOf(t.key)&&(t.to=ref(f,l?l[e]:s[e])||t.to)}return t}),m.length&&m.forEach(function(t){var e=s.indexOf(t),n=a[e],r=l?l[e]:s[e],o={children:n,key:s[e],item:r,to:ref(c,r),from:ref(u,r)};i=i.slice(0,e).concat([o],i.slice(e))}),_.length&&_.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:ref(p,n.item),from:ref(u,n.item),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var g=s.map(function(t){return i.find(function(e){return e.key===t})});i.forEach(function(t,e){t.destroy&&!g.find(function(e){return e.key===t.key})&&(g=g.slice(0,e).concat([t],g.slice(e)))}),this.setState({transitions:g,transitionKeys:r})},n.getValues=function(){},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.items,e.onFrame),o=(e.onRest,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","items","onFrame","onRest"])));return this.state.transitions.map(function(e,i){var r=e.key,s=e.item,l=e.children,u=_objectWithoutProperties(e,["key","item","children"]);return React.createElement(Spring,_extends({key:r},u,o,{onFrame:a&&function(t){return a(s,t)},render:n&&l,children:n?t.props.children:l}))})},e}(React.PureComponent);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default};var _class,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose(e,t);var n=e.prototype;return n.getValues=function(){return this.instance&&this.instance.getValues()},n.render=function(){var t=this,e=this.props,n=e.children,i=e.render,r=e.from,a=e.to,o=e.native,s=e.config,l=e.keys,u=e.onRest,c=_objectWithoutProperties(e,["children","render","from","to","native","config","keys","onRest"]),p=new Set,f=_extends({},c,{native:o,config:s,from:r,to:a});return(i||n).map(function(e,r){return React.createElement(Spring,_extends({ref:function(e){return 0===r&&(t.instance=e)},onRest:0===r?u:null,key:l[r]},f,{attach:function(t){return function(t,e){return p.add(e),0===t?void 0:Array.from(p)[t-1]}(r,t)},render:i&&e,children:i?n:e}))})},e}(React.PureComponent);function getScrollType(t){return t?"scrollLeft":"scrollTop"}Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps.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,r=getScrollType(n);this.scrollStop(),this.offset=t;var a=this.refs.container;this.animatedScroll=new exports$2.Value(a[r]),this.animatedScroll.addListener(function(t){var e=t.value;return a[r]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,u=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:u,overflowY:l?"hidden":u,overflowX:l?u:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class.contextTypes={parallax:PropTypes.object},_class.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps=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[getScrollType(n)])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal,r=getScrollType(i);t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[r]:t.refs.container[r]=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()}},Keyframes=function(t){function e(){for(var e,n,i=arguments.length,r=new Array(i),a=0;a<i;a++)r[a]=arguments[a];return e=n=t.call.apply(t,[this].concat(r))||this,n.state={primitive:void 0,props:{},resolve:function(){return null}},n.next=function(t,e){return new Promise(function(i){var r=n.instance&&n.instance.getValues(),a="function"==typeof e.from?e.from:_extends({},n.state.props.from,r,e.from);n.setState(function(n){return{primitive:t,props:_extends({},e,{from:a}),resolve:i}})})},e||_assertThisInitialized(n)}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){this.props.script&&this.props.script(this.next)},n.render=function(){var t=this,e=this.state,n=e.primitive,i=e.props,r=e.resolve,a=this.props,o=(a.script,_objectWithoutProperties(a,["script"]));return n?React.createElement(n,_extends({ref:function(e){return t.instance=e}},o,i,{onRest:r})):null},e}(React.Component);exports.Spring=Spring,exports.Keyframes=Keyframes,exports.Transition=Transition,exports.Trail=Trail,exports.Parallax=Parallax,exports.config=config,exports.template=template,exports.animated=animated,exports.interpolate=interpolate$1; | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var normalizeColor=_interopDefault(require("normalize-css-color")),React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types"));function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o._hey=1,o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){t instanceof AnimatedTracking&&(this._tracked=!0),0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if("function"==typeof t)return function(e){return t(e)};if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var a="extend";return void 0!==t.extrapolateRight?a=t.extrapolateRight:void 0!==t.extrapolate&&(a=t.extrapolate),function(t){var o=findRange(t,n);return interpolate(t,n[o],n[o+1],e[o],e[o+1],i,r,a)}},t}();function interpolate(t,e,n,i,r,a,o,s){var l=t;if(l<e){if("identity"===o)return l;"clamp"===o&&(l=e)}if(l>n){if("identity"===s)return l;"clamp"===s&&(l=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?l=-l:n===1/0?l-=e:l=(l-e)/(n-e),l=a(l),i===-1/0?l=-l:r===1/0?l+=i:l=l*(r-i)+i,l)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parents=Array.isArray(e)?e:[e],i._interpolation=Interpolation.create(n),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._interpolation.apply(this,this._parents.map(function(t){return t.__getValue()}))},n.__attach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._parents.length;++t)this._parents[t]instanceof Animated&&this._parents[t].__removeChild(this)},n.interpolate=function(t){return new e(this,t)},e}(AnimatedWithChildren),_uniqueId=0;function findAnimatedStyles(t,e){"function"==typeof t.update?e.add(t):t.__getChildren().forEach(function(t){return findAnimatedStyles(t,e)})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._animation=null,n._animatedStyles=new Set,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value},n._flush=function(){(0===this._animatedStyles.size||this._tracked)&&findAnimatedStyles(this,this._animatedStyles),this._animatedStyles.forEach(function(t){return t.update()})},n._updateValue=function(t){for(var e in this._value=t,this._flush(),this._listeners)this._listeners[e]({value:this.__getValue()})},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._animatedStyles.clear(),this._updateValue(t)},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,t)},n.animate=function(t,e){var n=this,i=this._animation;this._animation&&this._animation.stop(),this._animation=t,this._animatedStyles.clear(),t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,e&&e(t)},i)},n.addListener=function(t){var e=String(_uniqueId++);return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this)._values=e.map(function(t){return new AnimatedValue(t)}),n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e._values[n].setValue(t)})},n.__getValue=function(){return this._values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this._values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),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}(),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction},withDefault=function(t,e){return void 0===t||null===t?e:t},SpringAnimation=function(t){function e(e){var n;(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction;var i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7));return n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var a=r.getInternalState();this._lastPosition=a.lastPosition,this._lastVelocity=a.lastVelocity,this._lastTime=a.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var a=Math.floor((r-this._lastTime)/1),o=0;o<a;++o){var s=e,l=this._tension*(this._toValue-n)-this._friction*i,u=(n=t+.001*s/2,i=e+.001*l/2),c=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*u/2;var p=i=e+.001*c/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(u+p)+h)/6),e+=.001*((l+2*(c+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!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){return function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){!1===ApplyAnimatedValues.current(this.refs.node,t,this)&&this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){!1===ApplyAnimatedValues.current(e.refs.node,e._propsAnimated.__getAnimatedValue(),e)&&e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this._propsAnimated.__getValue(),n=e.style,i=_objectWithoutProperties(e,["style"]);return React.createElement(t,_extends({},i,{style:ApplyAnimatedValues.transformStyles(n),ref:"node"}))},n}(React.Component)}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,a=e.toValue;return t instanceof AnimatedArray?parallel(t._values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:a[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),a={start:function(e){if(n===t.length)return e&&e({finished:!0});t.forEach(function(o,s){var l=function(o){if(i[s]=!0,++n===t.length)return n=0,e&&e(o);!o.finished&&r&&a.stop()};o?o.start(l):l({finished:!0})})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return a},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},interpolate:function(t,e){return new AnimatedInterpolation(values,e)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function setValueForAttributes(t,e){var n;for(var i in e)"style"!==i&&(n=e[i],t.getAttribute(i)&&t.setAttribute(i,n))}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style),setValueForAttributes(t,e)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),animated=exports$2.elements,template=exports$2.template,interpolate$1=exports$2.interpolate,config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60}},Spring=function(t){function e(e){var n;return(n=t.call(this)||this).callback=function(){n.props.onFrame&&n.props.onFrame(n._propsAnimated.__getValue()),!n.props.native&&n.forceUpdate()},n._defaultAnimation=new exports$2.Value(0),n._animations={},n._updateProps(e,!1),n}_inheritsLoose(e,t);var n=e.prototype;return n._updateProps=function(t,e){var n=this,i=t.from,r=t.to,a=t.config,o=t.attach,s=t.immediate,l=t.reset,u=t.delay,c=(t.onFrame,t.onRest);void 0===e&&(e=!1);var p=Object.entries(_extends({},i,r)),f=this._defaultAnimation._value;this._interpolators={},this._defaultAnimation.setValue(0),this._animations=p.reduce(function(t,e,r){var u,p=e[0],h=e[1],d=!1===l&&n._animations[p]||(n._animations[p]={}),_="number"==typeof h,m=!_&&Array.isArray(h),v=void 0!==i[p]?i[p]:h,y=_||m?h:1;if(_&&o){var g=o(n),A=g&&g._animations[p];A&&(y=A.animation)}if(_)d.animation=d.interpolation=d.animation||new exports$2.Value(v);else if(m)d.animation=d.interpolation=d.animation||new exports$2.Array(v);else{var x=d.interpolation&&d.interpolation._interpolation(f);d.animation=n._defaultAnimation,d.interpolation=n._defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==x?x:v,h]})}return!s||!0!==s&&-1===s.indexOf(p)||d.animation.setValue(y),d.stopped=!1,d.start=function(){exports$2.spring(d.animation,_extends({toValue:y},a)).start(function(t){t.finished&&(n._animations[p].stopped=!0,Object.values(n._animations).every(function(t){return t.stopped})&&c&&c(_extends({},n.props.from,n.props.to)))})},d.stop=function(){return d.animation.stopAnimation()},n._interpolators[p]=d.interpolation,_extends({},t,((u={})[p]=d,u))},{}),e&&this.start({delay:u});var h=this._propsAnimated;this._propsAnimated=new exports$2.AnimatedProps(this._interpolators,this.callback),h&&h.__detach()},n.start=function(t){var e=this;return void 0===t&&(t=this.props),new Promise(function(n){var i=function(){Object.values(e._animations).forEach(function(t){return t.start()}),e._delay=void 0};t.delay>0?(e._delay&&clearTimeout(e._delay),e._delay=setTimeout(i,t.delay)):i()})},n.stop=function(){this._delay&&(clearTimeout(this._delay),this._delay=void 0),Object.values(this._animations).forEach(function(t){return t.stop()})},n.update=function(t){this._updateProps(_extends({},this.props,t),!0)},n.componentWillReceiveProps=function(t){this._updateProps(t,!0)},n.componentDidMount=function(){this.start()},n.componentWillUnmount=function(){this.stop()},n.getValues=function(){return this._propsAnimated.__getValue()},n.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=_extends({},i?this._interpolators:this._propsAnimated.__getValue(),r);return n?n(_extends({},a,{children:e})):Array.isArray(e)?e.map(function(t){return t(a)}):e(a)},e}(React.PureComponent);Spring.defaultProps={from:{},to:{},config:config.default,native:!1,immediate:!1,reset:!1,delay:0};var ref=function(t,e){return"function"==typeof t?t(e):t};function shallowDiffers(t,e){for(var n in t)if(!(n in e))return!0;for(var i in e)if(t[i]!==e[i])return!0;return!1}var Transition=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.items,s=e.from,l=e.enter,u=(e.leave,e.update);return i=r||i||function(){return null},"function"==typeof a&&(a=o.map(a)),Array.isArray(i)||(i=[i],a=a?[a]:i),n.state={transitionKeys:a,transitions:i.map(function(t,e){var n=o?o[e]:a[e];return{children:t,key:a[e],item:n,to:ref(l,n),from:ref(s,n),update:ref(u,n)}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.shouldComponentUpdate=function(t){return shallowDiffers(t,this.props)},n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionKeys,a=t.children,o=t.render,s=t.keys,l=t.items,u=t.from,c=t.enter,p=t.leave,f=t.update;a=o||a||function(){return null},"function"==typeof s&&(s=l.map(s)),Array.isArray(a)||(a=[a],s=s?[s]:a);var h=new Set(s),d=new Set(r),_=s.filter(function(t){return!d.has(t)}),m=r.filter(function(t){return!h.has(t)}),v=s.filter(function(t){return d.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n),f&&-1!==v.indexOf(t.key)&&(t.to=ref(f,l?l[e]:s[e])||t.to)}return t}),_.length&&_.forEach(function(t){var e=s.indexOf(t),n=a[e],r=l?l[e]:s[e],o={children:n,key:s[e],item:r,to:ref(c,r),from:ref(u,r)};i=i.slice(0,e).concat([o],i.slice(e))}),m.length&&m.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:n.key,to:ref(p,n.item),from:ref(u,n.item),onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var y=s.map(function(t){return i.find(function(e){return e.key===t})});i.forEach(function(t,e){t.destroy&&!y.find(function(e){return e.key===t.key})&&(y=y.slice(0,e).concat([t],y.slice(e)))}),this.setState({transitions:y,transitionKeys:r})},n.getValues=function(){},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),r=e.config,a=(e.keys,e.items,e.onFrame),o=(e.onRest,_extends({native:i,config:r},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys","items","onFrame","onRest"])));return this.state.transitions.map(function(e,i){var r=e.key,s=e.item,l=e.children,u=_objectWithoutProperties(e,["key","item","children"]);return React.createElement(Spring,_extends({key:r},u,o,{onFrame:a&&function(t){return a(s,t)},render:n&&l,children:n?t.props.children:l}))})},e}(React.Component);Transition.defaultProps={from:{},enter:{},leave:{},native:!1,config:config.default};var _class,_temp,Trail=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose(e,t);var n=e.prototype;return n.getValues=function(){return this.instance&&this.instance.getValues()},n.render=function(){var t=this,e=this.props,n=e.children,i=e.render,r=e.from,a=e.to,o=e.native,s=e.config,l=e.keys,u=e.onRest,c=_objectWithoutProperties(e,["children","render","from","to","native","config","keys","onRest"]),p=new Set,f=_extends({},c,{native:o,config:s,from:r,to:a});return(i||n).map(function(e,r){return React.createElement(Spring,_extends({ref:function(e){return 0===r&&(t.instance=e)},onRest:0===r?u:null,key:l[r]},f,{attach:function(t){return function(t,e){return p.add(e),0===t?void 0:Array.from(p)[t-1]}(r,t)},render:i&&e,children:i?n:e}))})},e}(React.PureComponent);function getScrollType(t){return t?"scrollLeft":"scrollTop"}Trail.defaultProps={from:{},to:{},native:!1,config:config.default};var Parallax=function(t){function e(e){var n;return n=t.call(this,e)||this,_initialiseProps.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,r=getScrollType(n);this.scrollStop(),this.offset=t;var a=this.refs.container;this.animatedScroll=new exports$2.Value(a[r]),this.animatedScroll.addListener(function(t){var e=t.value;return a[r]=e}),exports$2.spring(this.animatedScroll,_extends({toValue:t*this.space},i)).start()},n.getChildContext=function(){return{parallax:this}},n.componentDidMount=function(){window.addEventListener("resize",this.updateRaf,!1),this.update(),this.setState({ready:!0})},n.componentWillUnmount=function(){window.removeEventListener("resize",this.updateRaf,!1)},n.componentDidUpdate=function(){this.update()},n.render=function(){var t,e=this.props,n=e.style,i=e.innerStyle,r=e.pages,a=e.className,o=e.scrolling,s=e.children,l=e.horizontal,u=o?"scroll":"hidden";return React.createElement("div",{ref:"container",onScroll:this.onScroll,onWheel:o?this.scrollStop:null,onTouchStart:o?this.scrollStop:null,style:_extends({position:"absolute",width:"100%",height:"100%",overflow:u,overflowY:l?"hidden":u,overflowX:l?u:"hidden",WebkitOverflowScrolling:"touch",WebkitTransform:"translate(0,0)",MsTransform:"translate(0,0)",transform:"translate3d(0,0,0)"},n),className:a},this.state.ready&&React.createElement("div",{ref:"content",style:_extends((t={position:"absolute"},t[l?"height":"width"]="100%",t.WebkitTransform="translate(0,0)",t.MsTransform="translate(0,0)",t.transform="translate3d(0,0,0)",t.overflow="hidden",t[l?"width":"height"]=this.space*r,t),i)},s))},e}(React.PureComponent);Parallax.defaultProps={config:config.slow,scrolling:!0,horizontal:!1},Parallax.childContextTypes={parallax:PropTypes.object},Parallax.Layer=(_temp=_class=function(t){function e(e,n){var i;i=t.call(this,e,n)||this;var r=n.parallax,a=Math.floor(e.offset)*r.space,o=r.space*e.offset+a*e.speed,s=parseFloat(-r.current*e.speed+o);return i.animatedTranslate=new exports$2.Value(s),i.animatedSpace=new exports$2.Value(r.space*e.factor),i}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.parallax;t&&(t.layers=t.layers.concat(this),t.update())},n.componentWillUnmount=function(){var t=this,e=this.context.parallax;e&&(e.layers=e.layers.filter(function(e){return e!==t}),e.update())},n.setPosition=function(t,e,n){void 0===n&&(n=!1);var i=this.context.parallax.props.config,r=Math.floor(this.props.offset)*t,a=t*this.props.offset+r*this.props.speed,o=parseFloat(-e*this.props.speed+a);n?this.animatedTranslate.setValue(o):exports$2.spring(this.animatedTranslate,_extends({toValue:o},i)).start()},n.setHeight=function(t,e){void 0===e&&(e=!1);var n=this.context.parallax.props.config,i=parseFloat(t*this.props.factor);e?this.animatedSpace.setValue(i):exports$2.spring(this.animatedSpace,_extends({toValue:i},n)).start()},n.render=function(){var t,e=this.props,n=e.style,i=e.children,r=(e.offset,e.speed,e.factor,e.className),a=_objectWithoutProperties(e,["style","children","offset","speed","factor","className"]),o=this.context.parallax.props.horizontal,s=this.animatedTranslate.interpolate({inputRange:[0,1],outputRange:o?["translate3d(0px,0,0)","translate3d(1px,0,0)"]:["translate3d(0,0px,0)","translate3d(0,1px,0)"]});return React.createElement(animated.div,_extends({},a,{ref:"layer",className:r,style:_extends((t={position:"absolute",backgroundSize:"auto",backgroundRepeat:"no-repeat",willChange:"transform"},t[o?"height":"width"]="100%",t[o?"width":"height"]=this.animatedSpace,t.WebkitTransform=s,t.MsTransform=s,t.transform=s,t),n)}),i)},e}(React.PureComponent),_class.contextTypes={parallax:PropTypes.object},_class.defaultProps={factor:1,offset:0,speed:0},_temp);var _initialiseProps=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[getScrollType(n)])},this.update=function(){var e=t.props,n=e.scrolling,i=e.horizontal,r=getScrollType(i);t.refs.container&&(t.space=t.refs.container[i?"clientWidth":"clientHeight"],n?t.current=t.refs.container[r]:t.refs.container[r]=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()}},Keyframes=function(t){function e(){for(var e,n,i=arguments.length,r=new Array(i),a=0;a<i;a++)r[a]=arguments[a];return e=n=t.call.apply(t,[this].concat(r))||this,n.state={primitive:void 0,props:{},resolve:function(){return null}},n.next=function(t,e){return new Promise(function(i){var r=n.instance&&n.instance.getValues(),a="function"==typeof e.from?e.from:_extends({},n.state.props.from,r,e.from);n.setState(function(n){return{primitive:t,props:_extends({},e,{from:a}),resolve:i}})})},e||_assertThisInitialized(n)}_inheritsLoose(e,t);var n=e.prototype;return n.componentDidMount=function(){this.props.script&&this.props.script(this.next)},n.render=function(){var t=this,e=this.state,n=e.primitive,i=e.props,r=e.resolve,a=this.props,o=(a.script,_objectWithoutProperties(a,["script"]));return n?React.createElement(n,_extends({ref:function(e){return t.instance=e}},o,i,{onRest:r})):null},e}(React.Component);exports.Spring=Spring,exports.Keyframes=Keyframes,exports.Transition=Transition,exports.Trail=Trail,exports.Parallax=Parallax,exports.config=config,exports.template=template,exports.animated=animated,exports.interpolate=interpolate$1; |
{ | ||
"name": "react-spring", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"description": "Animate React with ease", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-spring", |
@@ -29,21 +29,22 @@ import React from 'react' | ||
reset: PropTypes.bool, | ||
delay: PropTypes.number, | ||
immediate: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.string)]), | ||
} | ||
static defaultProps = { from: {}, to: {}, config: config.default, native: false, immediate: false, reset: false } | ||
static defaultProps = { from: {}, to: {}, config: config.default, native: false, immediate: false, reset: false, delay: 0 } | ||
constructor(props) { | ||
super() | ||
this.defaultAnimation = new Animated.Value(0) | ||
this.animations = {} | ||
this.update(props, false) | ||
this._defaultAnimation = new Animated.Value(0) | ||
this._animations = {} | ||
this._updateProps(props, false) | ||
} | ||
update({ from, to, config, attach, immediate, reset, onFrame, onRest }, start = false) { | ||
_updateProps({ from, to, config, attach, immediate, reset, delay, onFrame, onRest }, start = false) { | ||
const allProps = Object.entries({ ...from, ...to }) | ||
const defaultAnimationValue = this.defaultAnimation._value | ||
const defaultAnimationValue = this._defaultAnimation._value | ||
this.interpolators = {} | ||
this.defaultAnimation.setValue(0) | ||
this.animations = allProps.reduce((acc, [name, value], i) => { | ||
const entry = (reset === false && this.animations[name]) || (this.animations[name] = {}) | ||
this._interpolators = {} | ||
this._defaultAnimation.setValue(0) | ||
this._animations = allProps.reduce((acc, [name, value], i) => { | ||
const entry = (reset === false && this._animations[name]) || (this._animations[name] = {}) | ||
let isNumber = typeof value === 'number' | ||
@@ -57,3 +58,3 @@ let isArray = !isNumber && Array.isArray(value) | ||
const target = attach(this) | ||
const targetAnimation = target && target.animations[name] | ||
const targetAnimation = target && target._animations[name] | ||
if (targetAnimation) toValue = targetAnimation.animation | ||
@@ -71,4 +72,4 @@ } | ||
const previous = entry.interpolation && entry.interpolation._interpolation(defaultAnimationValue) | ||
entry.animation = this.defaultAnimation | ||
entry.interpolation = this.defaultAnimation.interpolate({ | ||
entry.animation = this._defaultAnimation | ||
entry.interpolation = this._defaultAnimation.interpolate({ | ||
inputRange: [0, 1], | ||
@@ -85,4 +86,4 @@ outputRange: [previous !== undefined ? previous : fromValue, value], | ||
if (props.finished) { | ||
this.animations[name].stopped = true | ||
if (Object.values(this.animations).every(animation => animation.stopped)) | ||
this._animations[name].stopped = true | ||
if (Object.values(this._animations).every(animation => animation.stopped)) | ||
onRest && onRest({ ...this.props.from, ...this.props.to }) | ||
@@ -94,15 +95,40 @@ } | ||
this.interpolators[name] = entry.interpolation | ||
this._interpolators[name] = entry.interpolation | ||
return { ...acc, [name]: entry } | ||
}, {}) | ||
var oldPropsAnimated = this.propsAnimated | ||
this.propsAnimated = new Animated.AnimatedProps(this.interpolators, this.callback) | ||
if (start) this.start({ delay }) | ||
var oldPropsAnimated = this._propsAnimated | ||
this._propsAnimated = new Animated.AnimatedProps(this._interpolators, this.callback) | ||
oldPropsAnimated && oldPropsAnimated.__detach() | ||
} | ||
if (start) Object.values(this.animations).forEach(animation => animation.start()) | ||
start(props = this.props) { | ||
return new Promise(res => { | ||
const f = () => { | ||
Object.values(this._animations).forEach(animation => animation.start()) | ||
this._delay = undefined | ||
} | ||
if (props.delay > 0) { | ||
if (this._delay) clearTimeout(this._delay) | ||
this._delay = setTimeout(f, props.delay) | ||
} else f() | ||
}) | ||
} | ||
callback = v => { | ||
if (this.props.onFrame) this.props.onFrame(this.propsAnimated.__getValue()) | ||
stop() { | ||
if (this._delay) { | ||
clearTimeout(this._delay) | ||
this._delay = undefined | ||
} | ||
Object.values(this._animations).forEach(animation => animation.stop()) | ||
} | ||
update(props) { | ||
this._updateProps({ ...this.props, ...props }, true) | ||
} | ||
callback = () => { | ||
if (this.props.onFrame) this.props.onFrame(this._propsAnimated.__getValue()) | ||
!this.props.native && this.forceUpdate() | ||
@@ -112,15 +138,15 @@ } | ||
componentWillReceiveProps(props) { | ||
this.update(props, true) | ||
this._updateProps(props, true) | ||
} | ||
componentDidMount() { | ||
Object.values(this.animations).forEach(animation => animation.start()) | ||
this.start() | ||
} | ||
componentWillUnmount() { | ||
Object.values(this.animations).forEach(animation => animation.stop()) | ||
this.stop() | ||
} | ||
getValues() { | ||
return this.propsAnimated.__getValue() | ||
return this._propsAnimated.__getValue() | ||
} | ||
@@ -130,3 +156,3 @@ | ||
const { children, render, from, to, config, native, ...extra } = this.props | ||
let animatedProps = { ...(native ? this.interpolators : this.propsAnimated.__getValue()), ...extra } | ||
let animatedProps = { ...(native ? this._interpolators : this._propsAnimated.__getValue()), ...extra } | ||
if (render) return render({ ...animatedProps, children }) | ||
@@ -133,0 +159,0 @@ else return Array.isArray(children) ? children.map(child => child(animatedProps)) : children(animatedProps) |
@@ -8,3 +8,9 @@ import React from 'react' | ||
export default class Transition extends React.PureComponent { | ||
function shallowDiffers(a, b) { | ||
for (let i in a) if (!(i in b)) return true | ||
for (let i in b) if (a[i] !== b[i]) return true | ||
return false | ||
} | ||
export default class Transition extends React.Component { | ||
static propTypes = { | ||
@@ -50,2 +56,6 @@ native: PropTypes.bool, | ||
shouldComponentUpdate(nextProps) { | ||
return shallowDiffers(nextProps, this.props) | ||
} | ||
componentWillReceiveProps(props) { | ||
@@ -55,3 +65,3 @@ let { transitions, transitionKeys } = this.state | ||
children = render || children || (() => null) | ||
children = render || children || (() => null) | ||
if (typeof keys === 'function') keys = items.map(keys) | ||
@@ -58,0 +68,0 @@ if (!Array.isArray(children)) { |
218120
1897