react-spring
Advanced tools
Comparing version 2.2.2 to 2.3.0
@@ -1,1 +0,1 @@ | ||
import normalizeColor from"normalize-css-color";import invariant from"invariant";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}(),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange;checkInfiniteRange("outputRange",e);var n=t.inputRange;checkInfiniteRange("inputRange",n),checkValidInputRange(n),invariant(n.length===e.length,"inputRange ("+n.length+") and outputRange ("+e.length+") must have the same length");var 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){invariant("number"==typeof t,"Cannot interpolation an input which is not a number");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 u=t;if(u<e){if("identity"===o)return u;"clamp"===o&&(u=e)}if(u>n){if("identity"===s)return u;"clamp"===s&&(u=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?u=-u:n===1/0?u-=e:u=(u-e)/(n-e),u=a(u),i===-1/0?u=-u:r===1/0?u+=i:u=u*(r-i)+i,u)}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;invariant(e.length>=2,"Bad output range"),checkPattern(e=e.map(colorToRgba));var n=e[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 checkPattern(t){for(var e=t[0].replace(stringShapeRegex,""),n=1;n<t.length;++n)invariant(e===t[n].replace(stringShapeRegex,""),"invalid pattern "+t[0]+" and "+t[n])}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}function checkValidInputRange(t){invariant(t.length>=2,"inputRange must have at least 2 elements");for(var e=1;e<t.length;++e)invariant(t[e]>=t[e-1],"inputRange must be monotonically increasing "+t)}function checkInfiniteRange(t,e){invariant(e.length>=2,t+" must have at least 2 elements"),invariant(2!==e.length||e[0]!==-1/0||e[1]!==1/0,t+"cannot be ]-infinity;+infinity[ "+e)}var _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return invariant("number"==typeof t,"Cannot interpolate an input which is not a number."),this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},e}(AnimatedWithChildren),Animation=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},e}(AnimatedWithChildren),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var 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,u=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*u/2),l=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*l/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(c+p)+h)/6),e+=.001*((u+2*(l+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),_||m&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){var e=function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){this.refName&&ApplyAnimatedValues.current(this.refName,t,this)||this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){e.refName&&ApplyAnimatedValues.current(e.refName,e._propsAnimated.__getAnimatedValue(),e)||e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this,n=this._propsAnimated.__getValue();return React.createElement(t,_extends({},n,{ref:function(t){return e.refName=t}}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var spring=function(t,e){return{start:function(n){var i=t,r=e;e.toValue instanceof Animated?i.track(new AnimatedTracking(i,e.toValue,SpringAnimation,r,n)):i.animate(new SpringAnimation(r),n)},stop:function(){t.stopAnimation()}}},exports$1={Value:AnimatedValue,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20}};function createAnimation(t,e){var n,i,r;return i=n=function(e){function n(t){var n;return n=e.call(this)||this,r.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(t,!1),n}_inheritsLoose(n,e);var i=n.prototype;return i.update=function(e,n){var i=this,r=e.from,a=e.to,o=e.config,s=e.attach,u=e.immediate;void 0===n&&(n=!1);var c=Object.entries(_extends({},r,a)),l=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(e,a,c){var p,f=a[0],h=a[1],d=i.animations[f]||(i.animations[f]={}),_="number"==typeof h,m=void 0!==r[f]?r[f]:h,v=_?h:1;if(_&&s){var y=s(i),g=y&&y.animations[f];g&&(v=g.animation)}if(_)d.animation=d.interpolation=d.animation||new exports$2.Value(m);else{var A=d.interpolation&&d.interpolation._interpolation(l);d.animation=i.defaultAnimation,d.interpolation=i.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==A?A:m,h]})}return!u||!0!==u&&-1===u.indexOf(f)||d.animation.setValue(v),d.start=function(){return t(d.animation,_extends({toValue:v},o)).start(0===c&&i.onRest)},d.stop=function(){return d.animation.stopAnimation()},n&&d.start(),i.interpolators[f]=d.interpolation,_extends({},e,((p={})[f]=d,p))},{});var p=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),p&&p.__detach()},i.componentWillReceiveProps=function(t){this.update(t,!0)},i.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},i.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},i.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},a,r,{children:e})):e(_extends({},a,r))},n}(React.PureComponent),n.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])},n.defaultProps={from:{},to:{},config:e,native:!1,immediate:!1},r=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},i}function createTransition(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(a)||(a=[a]),n.state={transitionsKeys:a,transitions:i.map(function(t,e){return{children:t,key:a[e],to:s,from:o}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionsKeys,a=t.children,o=t.render,s=t.keys,u=t.from,c=t.enter,l=t.leave;a=o||a,Array.isArray(a)||(a=[a]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:a[e],key:t,to:c,from:u};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:l,from:u,onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,transitionsKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),a=e.config,o=(e.keys,_extends({native:i,config:a},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,a=e.children,s=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(r,_extends({key:i},s,o,{render:a,children:t.props.children})):React.createElement(r,_extends({key:i},s,o,{children:a}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},enter:{},leave:{},native:!1,config:e},i}function createTrail(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,a=t.to,o=t.native,s=t.config,u=t.keys,c=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),l=new Set,p=_extends({},c,{native:o,config:s,from:i,to:a});return(n||e).map(function(t,i){var a=function(t){return function(t,e){return l.add(e),0===t?void 0:Array.from(l)[t-1]}(i,t)};return n?React.createElement(r,_extends({key:u[i]},p,{attach:a,render:t,children:e})):React.createElement(r,_extends({key:u[i]},p,{attach:a,children:t}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},to:{},native:!1,config:e},i}var Spring=createAnimation(exports$2.spring,config.default),SpringTransition=createTransition(exports$2.spring,config.default),SpringTrail=createTrail(exports$2.spring,config.default),template=exports$2.template,animated=exports$2.elements;export{createAnimation,createTransition,createTrail,Spring,SpringTransition,SpringTrail,config,template,animated}; | ||
import normalizeColor from"normalize-css-color";import React from"react";import PropTypes from"prop-types";function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var o="extend";return void 0!==t.extrapolateRight?o=t.extrapolateRight:void 0!==t.extrapolate&&(o=t.extrapolate),function(t){var a=findRange(t,n);return interpolate(t,n[a],n[a+1],e[a],e[a+1],i,r,o)}},t}();function interpolate(t,e,n,i,r,o,a,s){var u=t;if(u<e){if("identity"===a)return u;"clamp"===a&&(u=e)}if(u>n){if("identity"===s)return u;"clamp"===s&&(u=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?u=-u:n===1/0?u-=e:u=(u-e)/(n-e),u=o(u),i===-1/0?u=-u:r===1/0?u+=i:u=u*(r-i)+i,u)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},e}(AnimatedWithChildren),Animation=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this).values=e.map(function(t){return new AnimatedValue(t)}),n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setValue(t)})},n.setOffset=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setOffset(t)})},n.flattenOffset=function(){this.values.forEach(function(t){return t.flattenOffset()})},n.__getValue=function(){return this.values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this.values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.addListener=function(t){var e=this,n=uniqueId(),i=function(n){n.value;return t(e.__getValue())};return this._listeners[n]=this.values.map(function(t){return t.addListener(i)}),n},n.removeListener=function(t){this.values.forEach(function(e){return e.removeListener(t)}),delete this._listeners[t]},n.__attach=function(){for(var t=0;t<this.values.length;++t)this.values[t]instanceof Animated&&this.values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this.values.length;++t)this.values[t]instanceof Animated&&this.values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTracking=function(t){function e(e,n,i,r,o){var a;return(a=t.call(this)||this)._value=e,a._parent=n,a._animationClass=i,a._animationConfig=r,a._callback=o,a.__attach(),a}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var o=r.getInternalState();this._lastPosition=o.lastPosition,this._lastVelocity=o.lastVelocity,this._lastTime=o.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var o=Math.floor((r-this._lastTime)/1),a=0;a<o;++a){var s=e,u=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*u/2),l=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*l/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(c+p)+h)/6),e+=.001*((u+2*(l+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),_||m&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){var e=function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){this.refName&&ApplyAnimatedValues.current(this.refName,t,this)||this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){e.refName&&ApplyAnimatedValues.current(e.refName,e._propsAnimated.__getAnimatedValue(),e)||e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this,n=this._propsAnimated.__getValue();return React.createElement(t,_extends({},n,{ref:function(t){return e.refName=t}}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,o=e.toValue;return t instanceof AnimatedArray?parallel(t.values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:o[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),o={start:function(e){n!==t.length?t.forEach(function(a,s){var u=function(a){if(i[s]=!0,++n===t.length)return n=0,void(e&&e(a));!a.finished&&r&&o.stop()};a?a.start(u):u({finished:!0})}):e&&e({finished:!0})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return o},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),o=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,o):n[i]=o}}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20}};function createAnimation(t,e){var n,i,r;return i=n=function(e){function n(t){var n;return n=e.call(this)||this,r.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(t,!1),n}_inheritsLoose(n,e);var i=n.prototype;return i.update=function(e,n){var i=this,r=e.from,o=e.to,a=e.config,s=e.attach,u=e.immediate;void 0===n&&(n=!1);var c=Object.entries(_extends({},r,o)),l=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(e,o,c){var p,f=o[0],h=o[1],d=i.animations[f]||(i.animations[f]={}),_="number"==typeof h,m=!_&&Array.isArray(h),v=void 0!==r[f]?r[f]:h,y=_||m?h:1;if(_&&s){var g=s(i),A=g&&g.animations[f];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 T=d.interpolation&&d.interpolation._interpolation(l);d.animation=i.defaultAnimation,d.interpolation=i.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==T?T:v,h]})}return!u||!0!==u&&-1===u.indexOf(f)||d.animation.setValue(y),d.start=function(){return t(d.animation,_extends({toValue:y},a)).start(0===c&&i.onRest)},d.stop=function(){return d.animation.stopAnimation()},n&&d.start(),i.interpolators[f]=d.interpolation,_extends({},e,((p={})[f]=d,p))},{});var p=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),p&&p.__detach()},i.componentWillReceiveProps=function(t){this.update(t,!0)},i.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},i.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},i.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),o=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},o,r,{children:e})):e(_extends({},o,r))},n}(React.PureComponent),n.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])},n.defaultProps={from:{},to:{},config:e,native:!1,immediate:!1},r=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},i}function createTransition(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,o=e.keys,a=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(o)||(o=[o]),n.state={transitionsKeys:o,transitions:i.map(function(t,e){return{children:t,key:o[e],to:s,from:a}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionsKeys,o=t.children,a=t.render,s=t.keys,u=t.from,c=t.enter,l=t.leave;o=a||o,Array.isArray(o)||(o=[o]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=o[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:o[e],key:t,to:c,from:u};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:l,from:u,onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,transitionsKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),o=e.config,a=(e.keys,_extends({native:i,config:o},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,o=e.children,s=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(r,_extends({key:i},s,a,{render:o,children:t.props.children})):React.createElement(r,_extends({key:i},s,a,{children:o}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},enter:{},leave:{},native:!1,config:e},i}function createTrail(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,o=t.to,a=t.native,s=t.config,u=t.keys,c=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),l=new Set,p=_extends({},c,{native:a,config:s,from:i,to:o});return(n||e).map(function(t,i){var o=function(t){return function(t,e){return l.add(e),0===t?void 0:Array.from(l)[t-1]}(i,t)};return n?React.createElement(r,_extends({key:u[i]},p,{attach:o,render:t,children:e})):React.createElement(r,_extends({key:u[i]},p,{attach:o,children:t}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},to:{},native:!1,config:e},i}var Spring=createAnimation(exports$2.spring,config.default),SpringTransition=createTransition(exports$2.spring,config.default),SpringTrail=createTrail(exports$2.spring,config.default),template=exports$2.template,animated=exports$2.elements;export{createAnimation,createTransition,createTrail,Spring,SpringTransition,SpringTrail,config,template,animated}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var normalizeColor=_interopDefault(require("normalize-css-color")),invariant=_interopDefault(require("invariant")),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}(),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange;checkInfiniteRange("outputRange",e);var n=t.inputRange;checkInfiniteRange("inputRange",n),checkValidInputRange(n),invariant(n.length===e.length,"inputRange ("+n.length+") and outputRange ("+e.length+") must have the same length");var 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){invariant("number"==typeof t,"Cannot interpolation an input which is not a number");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 u=t;if(u<e){if("identity"===o)return u;"clamp"===o&&(u=e)}if(u>n){if("identity"===s)return u;"clamp"===s&&(u=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?u=-u:n===1/0?u-=e:u=(u-e)/(n-e),u=a(u),i===-1/0?u=-u:r===1/0?u+=i:u=u*(r-i)+i,u)}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;invariant(e.length>=2,"Bad output range"),checkPattern(e=e.map(colorToRgba));var n=e[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 checkPattern(t){for(var e=t[0].replace(stringShapeRegex,""),n=1;n<t.length;++n)invariant(e===t[n].replace(stringShapeRegex,""),"invalid pattern "+t[0]+" and "+t[n])}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}function checkValidInputRange(t){invariant(t.length>=2,"inputRange must have at least 2 elements");for(var e=1;e<t.length;++e)invariant(t[e]>=t[e-1],"inputRange must be monotonically increasing "+t)}function checkInfiniteRange(t,e){invariant(e.length>=2,t+" must have at least 2 elements"),invariant(2!==e.length||e[0]!==-1/0||e[1]!==1/0,t+"cannot be ]-infinity;+infinity[ "+e)}var _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return invariant("number"==typeof t,"Cannot interpolate an input which is not a number."),this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},e}(AnimatedWithChildren),Animation=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},e}(AnimatedWithChildren),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTracking=function(t){function e(e,n,i,r,a){var o;return(o=t.call(this)||this)._value=e,o._parent=n,o._animationClass=i,o._animationConfig=r,o._callback=a,o.__attach(),o}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var 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,u=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*u/2),l=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*l/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(c+p)+h)/6),e+=.001*((u+2*(l+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),_||m&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){var e=function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){this.refName&&ApplyAnimatedValues.current(this.refName,t,this)||this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){e.refName&&ApplyAnimatedValues.current(e.refName,e._propsAnimated.__getAnimatedValue(),e)||e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this,n=this._propsAnimated.__getValue();return React.createElement(t,_extends({},n,{ref:function(t){return e.refName=t}}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var spring=function(t,e){return{start:function(n){var i=t,r=e;e.toValue instanceof Animated?i.track(new AnimatedTracking(i,e.toValue,SpringAnimation,r,n)):i.animate(new SpringAnimation(r),n)},stop:function(){t.stopAnimation()}}},exports$1={Value:AnimatedValue,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),a=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,a):n[i]=a}}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20}};function createAnimation(t,e){var n,i,r;return i=n=function(e){function n(t){var n;return n=e.call(this)||this,r.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(t,!1),n}_inheritsLoose(n,e);var i=n.prototype;return i.update=function(e,n){var i=this,r=e.from,a=e.to,o=e.config,s=e.attach,u=e.immediate;void 0===n&&(n=!1);var c=Object.entries(_extends({},r,a)),l=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(e,a,c){var p,f=a[0],h=a[1],d=i.animations[f]||(i.animations[f]={}),_="number"==typeof h,m=void 0!==r[f]?r[f]:h,v=_?h:1;if(_&&s){var y=s(i),g=y&&y.animations[f];g&&(v=g.animation)}if(_)d.animation=d.interpolation=d.animation||new exports$2.Value(m);else{var A=d.interpolation&&d.interpolation._interpolation(l);d.animation=i.defaultAnimation,d.interpolation=i.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==A?A:m,h]})}return!u||!0!==u&&-1===u.indexOf(f)||d.animation.setValue(v),d.start=function(){return t(d.animation,_extends({toValue:v},o)).start(0===c&&i.onRest)},d.stop=function(){return d.animation.stopAnimation()},n&&d.start(),i.interpolators[f]=d.interpolation,_extends({},e,((p={})[f]=d,p))},{});var p=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),p&&p.__detach()},i.componentWillReceiveProps=function(t){this.update(t,!0)},i.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},i.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},i.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),a=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},a,r,{children:e})):e(_extends({},a,r))},n}(React.PureComponent),n.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])},n.defaultProps={from:{},to:{},config:e,native:!1,immediate:!1},r=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},i}function createTransition(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,a=e.keys,o=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(a)||(a=[a]),n.state={transitionsKeys:a,transitions:i.map(function(t,e){return{children:t,key:a[e],to:s,from:o}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionsKeys,a=t.children,o=t.render,s=t.keys,u=t.from,c=t.enter,l=t.leave;a=o||a,Array.isArray(a)||(a=[a]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=a[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:a[e],key:t,to:c,from:u};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:l,from:u,onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,transitionsKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),a=e.config,o=(e.keys,_extends({native:i,config:a},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,a=e.children,s=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(r,_extends({key:i},s,o,{render:a,children:t.props.children})):React.createElement(r,_extends({key:i},s,o,{children:a}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},enter:{},leave:{},native:!1,config:e},i}function createTrail(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,a=t.to,o=t.native,s=t.config,u=t.keys,c=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),l=new Set,p=_extends({},c,{native:o,config:s,from:i,to:a});return(n||e).map(function(t,i){var a=function(t){return function(t,e){return l.add(e),0===t?void 0:Array.from(l)[t-1]}(i,t)};return n?React.createElement(r,_extends({key:u[i]},p,{attach:a,render:t,children:e})):React.createElement(r,_extends({key:u[i]},p,{attach:a,children:t}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},to:{},native:!1,config:e},i}var Spring=createAnimation(exports$2.spring,config.default),SpringTransition=createTransition(exports$2.spring,config.default),SpringTrail=createTrail(exports$2.spring,config.default),template=exports$2.template,animated=exports$2.elements;exports.createAnimation=createAnimation,exports.createTransition=createTransition,exports.createTrail=createTrail,exports.Spring=Spring,exports.SpringTransition=SpringTransition,exports.SpringTrail=SpringTrail,exports.config=config,exports.template=template,exports.animated=animated; | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var normalizeColor=_interopDefault(require("normalize-css-color")),React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types"));function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function _objectWithoutProperties(t,e){if(null==t)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var Animated=function(){function t(){}var e=t.prototype;return e.__attach=function(){},e.__detach=function(){},e.__getValue=function(){},e.__getAnimatedValue=function(){return this.__getValue()},e.__addChild=function(t){},e.__removeChild=function(t){},e.__getChildren=function(){return[]},t}(),AnimatedWithChildren=function(t){function e(){var e;return(e=t.call(this)||this)._children=[],e}_inheritsLoose(e,t);var n=e.prototype;return n.__addChild=function(t){0===this._children.length&&this.__attach(),this._children.push(t)},n.__removeChild=function(t){var e=this._children.indexOf(t);-1!==e?(this._children.splice(e,1),0===this._children.length&&this.__detach()):console.warn("Trying to remove a child that doesn't exist")},n.__getChildren=function(){return this._children},e}(Animated),InteractionManager={current:{createInteractionHandle:function(){},clearInteractionHandle:function(){}},inject:function(t){InteractionManager.current=t}},linear=function(t){return t},Interpolation=function(){function t(){}return t.create=function(t){if(t.outputRange&&"string"==typeof t.outputRange[0])return createInterpolationFromStringOutputRange(t);var e=t.outputRange,n=t.inputRange,i=t.easing||linear,r="extend";void 0!==t.extrapolateLeft?r=t.extrapolateLeft:void 0!==t.extrapolate&&(r=t.extrapolate);var o="extend";return void 0!==t.extrapolateRight?o=t.extrapolateRight:void 0!==t.extrapolate&&(o=t.extrapolate),function(t){var a=findRange(t,n);return interpolate(t,n[a],n[a+1],e[a],e[a+1],i,r,o)}},t}();function interpolate(t,e,n,i,r,o,a,s){var u=t;if(u<e){if("identity"===a)return u;"clamp"===a&&(u=e)}if(u>n){if("identity"===s)return u;"clamp"===s&&(u=n)}return i===r?i:e===n?t<=e?i:r:(e===-1/0?u=-u:n===1/0?u-=e:u=(u-e)/(n-e),u=o(u),i===-1/0?u=-u:r===1/0?u+=i:u=u*(r-i)+i,u)}function colorToRgba(t){var e=normalizeColor(t);return null===e?t:"rgba("+((4278190080&(e=e||0))>>>24)+", "+((16711680&e)>>>16)+", "+((65280&e)>>>8)+", "+(255&e)/255+")"}var stringShapeRegex=/[0-9\.-]+/g;function createInterpolationFromStringOutputRange(t){var e=t.outputRange,n=(e=e.map(colorToRgba))[0].match(stringShapeRegex).map(function(){return[]});e.forEach(function(t){t.match(stringShapeRegex).forEach(function(t,e){n[e].push(+t)})});var i=e[0].match(stringShapeRegex).map(function(e,i){return Interpolation.create(_extends({},t,{outputRange:n[i]}))}),r=/^rgb/.test(e[0]);return function(t){var n=0;return e[0].replace(stringShapeRegex,function(){var e=i[n++](t);return String(r&&n<4?Math.round(e):e)})}}function findRange(t,e){for(var n=1;n<e.length-1&&!(e[n]>=t);++n);return n-1}var _uniqueId=0;function uniqueId(){return String(_uniqueId++)}var AnimatedInterpolation=function(t){function e(e,n){var i;return(i=t.call(this)||this)._parent=e,i._interpolation=n,i._listeners={},i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t=this._parent.__getValue();return this._interpolation(t)},n.addListener=function(t){var e=this;this._parentListener||(this._parentListener=this._parent.addListener(function(){for(var t in e._listeners)e._listeners[t]({value:e.__getValue()})}));var n=uniqueId();return this._listeners[n]=t,n},n.removeListener=function(t){delete this._listeners[t]},n.interpolate=function(t){return new e(this,Interpolation.create(t))},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this),this._parentListener=this._parent.removeListener(this._parentListener)},e}(AnimatedWithChildren),Animation=function(){function t(){}var e=t.prototype;return e.start=function(t,e,n,i){},e.stop=function(){},e.__debouncedOnEnd=function(t){var e=this.__onEnd;this.__onEnd=null,e&&e(t)},t}();function _flush(t){var e=new Set;!function t(n){"function"==typeof n.update?e.add(n):n.__getChildren().forEach(t)}(t),e.forEach(function(t){return t.update()})}var AnimatedValue=function(t){function e(e){var n;return(n=t.call(this)||this)._value=e,n._offset=0,n._animation=null,n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.__detach=function(){this.stopAnimation()},n.__getValue=function(){return this._value+this._offset},n.setValue=function(t){this._animation&&(this._animation.stop(),this._animation=null),this._updateValue(t)},n.setOffset=function(t){this._offset=t},n.flattenOffset=function(){this._value+=this._offset,this._offset=0},n.addListener=function(t){var e=uniqueId();return this._listeners[e]=t,e},n.removeListener=function(t){delete this._listeners[t]},n.removeAllListeners=function(){this._listeners={}},n.stopAnimation=function(t){this.stopTracking(),this._animation&&this._animation.stop(),this._animation=null,t&&t(this.__getValue())},n.interpolate=function(t){return new AnimatedInterpolation(this,Interpolation.create(t))},n.animate=function(t,e){var n=this,i=null;t.__isInteraction&&(i=InteractionManager.current.createInteractionHandle());var r=this._animation;this._animation&&this._animation.stop(),this._animation=t,t.start(this._value,function(t){return n._updateValue(t)},function(t){n._animation=null,null!==i&&InteractionManager.current.clearInteractionHandle(i),e&&e(t)},r)},n.stopTracking=function(){this._tracking&&this._tracking.__detach(),this._tracking=null},n.track=function(t){this.stopTracking(),this._tracking=t},n._updateValue=function(t){for(var e in this._value=t,_flush(this),this._listeners)this._listeners[e]({value:this.__getValue()})},e}(AnimatedWithChildren),AnimatedArray=function(t){function e(e){var n;return(n=t.call(this)||this).values=e.map(function(t){return new AnimatedValue(t)}),n._listeners={},n}_inheritsLoose(e,t);var n=e.prototype;return n.setValue=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setValue(t)})},n.setOffset=function(t){var e=this;t.forEach(function(t,n){return e.values[n].setOffset(t)})},n.flattenOffset=function(){this.values.forEach(function(t){return t.flattenOffset()})},n.__getValue=function(){return this.values.map(function(t){return t.__getValue()})},n.stopAnimation=function(t){this.values.forEach(function(t){return t.stopAnimation()}),t&&t(this.__getValue())},n.addListener=function(t){var e=this,n=uniqueId(),i=function(n){n.value;return t(e.__getValue())};return this._listeners[n]=this.values.map(function(t){return t.addListener(i)}),n},n.removeListener=function(t){this.values.forEach(function(e){return e.removeListener(t)}),delete this._listeners[t]},n.__attach=function(){for(var t=0;t<this.values.length;++t)this.values[t]instanceof Animated&&this.values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this.values.length;++t)this.values[t]instanceof Animated&&this.values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTemplate=function(t){function e(e,n){var i;return(i=t.call(this)||this)._strings=e,i._values=n,i}_inheritsLoose(e,t);var n=e.prototype;return n.__transformValue=function(t){return t instanceof Animated?t.__getValue():t},n.__getValue=function(){for(var t=this._strings[0],e=0;e<this._values.length;++e)t+=this.__transformValue(this._values[e])+this._strings[1+e];return t},n.__attach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__addChild(this)},n.__detach=function(){for(var t=0;t<this._values.length;++t)this._values[t]instanceof Animated&&this._values[t].__removeChild(this)},e}(AnimatedWithChildren),AnimatedTracking=function(t){function e(e,n,i,r,o){var a;return(a=t.call(this)||this)._value=e,a._parent=n,a._animationClass=i,a._animationConfig=r,a._callback=o,a.__attach(),a}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){return this._parent.__getValue()},n.__attach=function(){this._parent.__addChild(this)},n.__detach=function(){this._parent.__removeChild(this)},n.update=function(){this._value.animate(new this._animationClass(_extends({},this._animationConfig,{toValue:this._animationConfig.toValue.__getValue()})),this._callback)},e}(Animated),RequestAnimationFrame={current:function(t){return global.requestAnimationFrame(t)},inject:function(t){RequestAnimationFrame.current=t}},CancelAnimationFrame={current:function(t){return global.cancelAnimationFrame(t)},inject:function(t){CancelAnimationFrame.current=t}};function tensionFromOrigamiValue(t){return 3.62*(t-30)+194}function frictionFromOrigamiValue(t){return 3*(t-8)+25}function fromOrigamiTensionAndFriction(t,e){return{tension:tensionFromOrigamiValue(t),friction:frictionFromOrigamiValue(e)}}var SpringConfig={fromOrigamiTensionAndFriction:fromOrigamiTensionAndFriction};function withDefault(t,e){return void 0===t||null===t?e:t}var SpringAnimation=function(t){function e(e){var n,i;return(n=t.call(this)||this)._overshootClamping=withDefault(e.overshootClamping,!1),n._restDisplacementThreshold=withDefault(e.restDisplacementThreshold,.001),n._restSpeedThreshold=withDefault(e.restSpeedThreshold,.001),n._initialVelocity=e.velocity,n._lastVelocity=withDefault(e.velocity,0),n._toValue=e.toValue,n.__isInteraction=void 0===e.isInteraction||e.isInteraction,i=SpringConfig.fromOrigamiTensionAndFriction(withDefault(e.tension,40),withDefault(e.friction,7)),n._tension=i.tension,n._friction=i.friction,n}_inheritsLoose(e,t);var n=e.prototype;return n.start=function(t,n,i,r){if(this.__active=!0,this._startPosition=t,this._lastPosition=this._startPosition,this._onUpdate=n,this.__onEnd=i,this._lastTime=Date.now(),r instanceof e){var o=r.getInternalState();this._lastPosition=o.lastPosition,this._lastVelocity=o.lastVelocity,this._lastTime=o.lastTime}void 0!==this._initialVelocity&&null!==this._initialVelocity&&(this._lastVelocity=this._initialVelocity),this.onUpdate()},n.getInternalState=function(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime}},n.onUpdate=function(){var t=this._lastPosition,e=this._lastVelocity,n=this._lastPosition,i=this._lastVelocity,r=Date.now();r>this._lastTime+64&&(r=this._lastTime+64);for(var o=Math.floor((r-this._lastTime)/1),a=0;a<o;++a){var s=e,u=this._tension*(this._toValue-n)-this._friction*i,c=(n=t+.001*s/2,i=e+.001*u/2),l=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*c/2;var p=i=e+.001*l/2,f=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2;var h=i=e+.001*f/2,d=this._tension*(this._toValue-n)-this._friction*i;n=t+.001*p/2,i=e+.001*f/2,t+=.001*((s+2*(c+p)+h)/6),e+=.001*((u+2*(l+f)+d)/6)}if(this._lastTime=r,this._lastPosition=t,this._lastVelocity=e,this._onUpdate(t),this.__active){var _=!1;this._overshootClamping&&0!==this._tension&&(_=this._startPosition<this._toValue?t>this._toValue:t<this._toValue);var m=Math.abs(e)<=this._restSpeedThreshold,v=!0;if(0!==this._tension&&(v=Math.abs(this._toValue-t)<=this._restDisplacementThreshold),_||m&&v)return 0!==this._tension&&this._onUpdate(this._toValue),void this.__debouncedOnEnd({finished:!0});this._animationFrame=RequestAnimationFrame.current(this.onUpdate.bind(this))}},n.stop=function(){this.__active=!1,CancelAnimationFrame.current(this._animationFrame),this.__debouncedOnEnd({finished:!1})},e}(Animation),FlattenStyle={current:function(t){return t},inject:function(t){FlattenStyle.current=t}},AnimatedStyle=function(t){function e(e){var n;return n=t.call(this)||this,e=FlattenStyle.current(e)||{},n._style=e,n}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._style){var n=this._style[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._style){var n=this._style[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._style){var e=this._style[t];e instanceof Animated&&e.__removeChild(this)}},e}(AnimatedWithChildren),AnimatedProps=function(t){function e(e,n){var i;return i=t.call(this)||this,e.style&&(e=_extends({},e,{style:new AnimatedStyle(e.style)})),i._props=e,i._callback=n,i.__attach(),i}_inheritsLoose(e,t);var n=e.prototype;return n.__getValue=function(){var t={};for(var e in this._props){var n=this._props[e];t[e]=n instanceof Animated?n.__getValue():n}return t},n.__getAnimatedValue=function(){var t={};for(var e in this._props){var n=this._props[e];n instanceof Animated&&(t[e]=n.__getAnimatedValue())}return t},n.__attach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__addChild(this)}},n.__detach=function(){for(var t in this._props){var e=this._props[t];e instanceof Animated&&e.__removeChild(this)}},n.update=function(){this._callback()},e}(Animated),ApplyAnimatedValues={current:function(t,e){if(!t.setNativeProps)return!1;t.setNativeProps(e)},transformStyles:function(t){return t},inject:function(t,e){ApplyAnimatedValues.current=t,ApplyAnimatedValues.transformStyles=e}};function createAnimatedComponent(t){var e=function(e){function n(){return e.apply(this,arguments)||this}_inheritsLoose(n,e);var i=n.prototype;return i.componentWillUnmount=function(){this._propsAnimated&&this._propsAnimated.__detach()},i.setNativeProps=function(t){this.refName&&ApplyAnimatedValues.current(this.refName,t,this)||this.forceUpdate()},i.componentWillMount=function(){this.attachProps(this.props)},i.attachProps=function(t){var e=this,n=this._propsAnimated;this._propsAnimated=new AnimatedProps(t,function(){e.refName&&ApplyAnimatedValues.current(e.refName,e._propsAnimated.__getAnimatedValue(),e)||e.forceUpdate()}),n&&n.__detach()},i.componentWillReceiveProps=function(t){this.attachProps(t)},i.render=function(){var e=this,n=this._propsAnimated.__getValue();return React.createElement(t,_extends({},n,{ref:function(t){return e.refName=t}}))},n}(React.Component);return"production"!==process.env.NODE_ENV&&(e.propTypes={style:function(e,n,i){t.propTypes}}),e}var maybeVectorAnim=function(t,e,n){var i=e.tension,r=e.friction,o=e.toValue;return t instanceof AnimatedArray?parallel(t.values.map(function(t,e){return n(t,{tension:i,friction:r,toValue:o[e]})}),{stopTogether:!1}):null},spring=function t(e,n){return maybeVectorAnim(e,n,t)||{start:function(t){var i=e,r=n;i.stopTracking(),n.toValue instanceof Animated?i.track(new AnimatedTracking(i,n.toValue,SpringAnimation,r,t)):i.animate(new SpringAnimation(r),t)},stop:function(){e.stopAnimation()}}},parallel=function(t,e){var n=0,i={},r=!(e&&!1===e.stopTogether),o={start:function(e){n!==t.length?t.forEach(function(a,s){var u=function(a){if(i[s]=!0,++n===t.length)return n=0,void(e&&e(a));!a.finished&&r&&o.stop()};a?a.start(u):u({finished:!0})}):e&&e({finished:!0})},stop:function(){t.forEach(function(t,e){!i[e]&&t.stop(),i[e]=!0})}};return o},exports$1={Value:AnimatedValue,Array:AnimatedArray,spring:spring,template:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new AnimatedTemplate(t,n)},createAnimatedComponent:createAnimatedComponent,inject:{ApplyAnimatedValues:ApplyAnimatedValues.inject,InteractionManager:InteractionManager.inject,FlattenStyle:FlattenStyle.inject,RequestAnimationFrame:RequestAnimationFrame.inject,CancelAnimationFrame:CancelAnimationFrame.inject},ApplyAnimatedValues:ApplyAnimatedValues,AnimatedProps:AnimatedProps},isUnitlessNumber={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};function prefixKey(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}var prefixes=["Webkit","ms","Moz","O"];function mapStyle(t){return t}function dangerousStyleValue(t,e,n){return null==e||"boolean"==typeof e||""===e?"":n||"number"!=typeof e||0===e||isUnitlessNumber.hasOwnProperty(t)&&isUnitlessNumber[t]?(""+e).trim():e+"px"}function setValueForStyles(t,e){var n=t.style;for(var i in e)if(e.hasOwnProperty(i)){var r=0===i.indexOf("--"),o=dangerousStyleValue(i,e[i],r);"float"===i&&(i="cssFloat"),r?n.setProperty(i,o):n[i]=o}}function ApplyAnimatedValues$1(t,e){if(t.setNativeProps)t.setNativeProps(e);else{if(!t.nodeType||void 0===t.setAttribute)return!1;setValueForStyles(t,e.style)}}Object.keys(isUnitlessNumber).forEach(function(t){prefixes.forEach(function(e){isUnitlessNumber[prefixKey(e,t)]=isUnitlessNumber[t]})}),exports$1.inject.ApplyAnimatedValues(ApplyAnimatedValues$1,mapStyle);var elements=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].reduce(function(t,e){var n;return _extends({},t,((n={})[e]=exports$1.createAnimatedComponent(e),n))},{}),exports$2=_extends({},exports$1,{elements:elements}),config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20}};function createAnimation(t,e){var n,i,r;return i=n=function(e){function n(t){var n;return n=e.call(this)||this,r.call(_assertThisInitialized(n)),n.defaultAnimation=new exports$2.Value(0),n.animations={},n.update(t,!1),n}_inheritsLoose(n,e);var i=n.prototype;return i.update=function(e,n){var i=this,r=e.from,o=e.to,a=e.config,s=e.attach,u=e.immediate;void 0===n&&(n=!1);var c=Object.entries(_extends({},r,o)),l=this.defaultAnimation._value;this.interpolators={},this.defaultAnimation.setValue(0),this.animations=c.reduce(function(e,o,c){var p,f=o[0],h=o[1],d=i.animations[f]||(i.animations[f]={}),_="number"==typeof h,m=!_&&Array.isArray(h),v=void 0!==r[f]?r[f]:h,y=_||m?h:1;if(_&&s){var g=s(i),A=g&&g.animations[f];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 T=d.interpolation&&d.interpolation._interpolation(l);d.animation=i.defaultAnimation,d.interpolation=i.defaultAnimation.interpolate({inputRange:[0,1],outputRange:[void 0!==T?T:v,h]})}return!u||!0!==u&&-1===u.indexOf(f)||d.animation.setValue(y),d.start=function(){return t(d.animation,_extends({toValue:y},a)).start(0===c&&i.onRest)},d.stop=function(){return d.animation.stopAnimation()},n&&d.start(),i.interpolators[f]=d.interpolation,_extends({},e,((p={})[f]=d,p))},{});var p=this.propsAnimated;this.propsAnimated=new exports$2.AnimatedProps(this.interpolators,this.callback),p&&p.__detach()},i.componentWillReceiveProps=function(t){this.update(t,!0)},i.componentDidMount=function(){Object.values(this.animations).forEach(function(t){return(0,t.start)()})},i.componentWillUnmount=function(){Object.values(this.animations).forEach(function(t){return(0,t.stop)()})},i.render=function(){var t=this.props,e=t.children,n=t.render,i=(t.from,t.to,t.config,t.native),r=_objectWithoutProperties(t,["children","render","from","to","config","native"]),o=i?this.interpolators:this.propsAnimated.__getValue();return n?n(_extends({},o,r,{children:e})):e(_extends({},o,r))},n}(React.PureComponent),n.propTypes={to:PropTypes.oneOfType([PropTypes.object,PropTypes.func]),from:PropTypes.object,config:PropTypes.object,native:PropTypes.bool,onRest:PropTypes.func,children:PropTypes.func,render:PropTypes.func,immediate:PropTypes.oneOfType([PropTypes.bool,PropTypes.arrayOf(PropTypes.string)])},n.defaultProps={from:{},to:{},config:e,native:!1,immediate:!1},r=function(){var t=this;this.callback=function(){return!t.props.native&&t.forceUpdate()},this.onRest=function(e){return e.finished&&t.props.onRest&&t.props.onRest()}},i}function createTransition(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(e){var n;n=t.call(this)||this;var i=e.children,r=e.render,o=e.keys,a=e.from,s=e.enter;e.leave;return i=r||i,Array.isArray(i)||(i=[i]),Array.isArray(o)||(o=[o]),n.state={transitionsKeys:o,transitions:i.map(function(t,e){return{children:t,key:o[e],to:s,from:a}})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=this,n=this.state,i=n.transitions,r=n.transitionsKeys,o=t.children,a=t.render,s=t.keys,u=t.from,c=t.enter,l=t.leave;o=a||o,Array.isArray(o)||(o=[o]),Array.isArray(s)||(s=[s]);var p=new Set(s),f=new Set(r),h=s.filter(function(t){return!f.has(t)}),d=r.filter(function(t){return!p.has(t)});i=i.map(function(t){if(void 0===t.destroy){var e=s.indexOf(t.key),n=o[e];n&&(t.children=n)}return t}),h.length&&h.forEach(function(t){var e=s.indexOf(t),n={children:o[e],key:t,to:c,from:u};i=i.slice(0,e).concat([n],i.slice(e))}),d.length&&d.forEach(function(t){var n=i.find(function(e){return e.key===t});if(n){var r={destroy:!0,children:n.children,key:t,to:l,from:u,onRest:function(){return e.setState(function(t){return{transitions:t.transitions.filter(function(t){return t!==r})}})}};i=i.map(function(t){return t===n?r:t})}}),r=i.filter(function(t){return void 0===t.destroy}).map(function(t){return t.key});var _=s.map(function(t){return i.find(function(e){return e.key===t})});d.forEach(function(t){var e=i.findIndex(function(e){return e.key===t}),n=i.find(function(e){return e.key===t});n&&(_=_.slice(0,e).concat([n],_.slice(e)))}),this.setState({transitions:_,transitionsKeys:r})},n.render=function(){var t=this,e=this.props,n=e.render,i=(e.from,e.enter,e.leave,e.native),o=e.config,a=(e.keys,_extends({native:i,config:o},_objectWithoutProperties(e,["render","from","enter","leave","native","config","keys"])));return this.state.transitions.map(function(e){var i=e.key,o=e.children,s=_objectWithoutProperties(e,["key","children"]);return n?React.createElement(r,_extends({key:i},s,a,{render:o,children:t.props.children})):React.createElement(r,_extends({key:i},s,a,{children:o}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,enter:PropTypes.object,leave:PropTypes.object,keys:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),PropTypes.oneOfType([PropTypes.string,PropTypes.number])]),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},enter:{},leave:{},native:!1,config:e},i}function createTrail(t,e){var n,i,r=createAnimation(t,e);return i=n=function(t){function e(){return t.apply(this,arguments)||this}return _inheritsLoose(e,t),e.prototype.render=function(){var t=this.props,e=t.children,n=t.render,i=t.from,o=t.to,a=t.native,s=t.config,u=t.keys,c=_objectWithoutProperties(t,["children","render","from","to","native","config","keys"]),l=new Set,p=_extends({},c,{native:a,config:s,from:i,to:o});return(n||e).map(function(t,i){var o=function(t){return function(t,e){return l.add(e),0===t?void 0:Array.from(l)[t-1]}(i,t)};return n?React.createElement(r,_extends({key:u[i]},p,{attach:o,render:t,children:e})):React.createElement(r,_extends({key:u[i]},p,{attach:o,children:t}))})},e}(React.PureComponent),n.propTypes={native:PropTypes.bool,config:PropTypes.object,from:PropTypes.object,to:PropTypes.object,keys:PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,PropTypes.number])),children:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func]),render:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func),PropTypes.func])},n.defaultProps={from:{},to:{},native:!1,config:e},i}var Spring=createAnimation(exports$2.spring,config.default),SpringTransition=createTransition(exports$2.spring,config.default),SpringTrail=createTrail(exports$2.spring,config.default),template=exports$2.template,animated=exports$2.elements;exports.createAnimation=createAnimation,exports.createTransition=createTransition,exports.createTrail=createTrail,exports.Spring=Spring,exports.SpringTransition=SpringTransition,exports.SpringTrail=SpringTrail,exports.config=config,exports.template=template,exports.animated=animated; |
{ | ||
"name": "react-spring", | ||
"version": "2.2.2", | ||
"version": "2.3.0", | ||
"description": "Animate React with ease", | ||
@@ -58,5 +58,4 @@ "main": "dist/react-spring", | ||
"dependencies": { | ||
"invariant": "^2.2.3", | ||
"normalize-css-color": "^1.0.2" | ||
} | ||
} |
@@ -42,3 +42,3 @@ [![Build Status](https://travis-ci.org/drcmda/react-spring.svg?branch=master)](https://travis-ci.org/drcmda/react-spring) [![npm version](https://badge.fury.io/js/react-spring.svg)](https://badge.fury.io/js/react-spring) | ||
to={{ | ||
// Can be numbers, colors, paths, degrees, percentages, ... | ||
// Can be numbers, colors, paths, degrees, percentages, arrays, ... | ||
start: toggle ? '#abc' : 'rgb(10,20,30)', | ||
@@ -69,10 +69,16 @@ end: toggle ? 'seagreen' : 'rgba(0,0,0,0.5)', | ||
```jsx | ||
const Header = ({ text, ...styles }) => <h1 style={styles}>{text}</h1> | ||
const Header = ({ children, ...styles }) => ( | ||
<h1 style={styles}> | ||
{children} | ||
</h1> | ||
) | ||
const App = () => ( | ||
<Spring to={{ color: 'red' }} text="extra props are spread over the child" children={Header}/> | ||
const App = ({ color, children }) => ( | ||
<Spring to={{ color }} render={Header}> | ||
{children} | ||
</Spring> | ||
) | ||
``` | ||
Et voilà! Now you render a animated version of the `Header` component! All props that `Spring` doesn't recognize as its own will be spread over the component, so you can still communicate locals to it. It's actually faster as well since the function isn't recreated on every prop-change. | ||
Et voilà! Now you render a animated version of the `Header` component! All props that `Spring` doesn't recognize as its own will be spread over the receiving component, including `children` if you use `render` instead. It's actually faster as well since the function isn't recreated on every prop-change. | ||
@@ -83,5 +89,7 @@ # Native rendering 🚀 | ||
Pass the `native` flag for more performance. The animations will be applied to the dom, skipping any React render passes. Just be aware of the following conditions: | ||
Pass the `native` flag for more performance. The animations will now be applied *directly* to the dom through requestAnimationFrame and the component will only render when it receives new props. The flag is available for all primitives (Spring, SpringTransition & SpringTrail). | ||
1. You can only animate styles and standard props, the values you receive are opaque objects, not regular values | ||
Just be aware of the following conditions: | ||
1. It only animates standard styles and element props, the values you receive *are opaque objects, not regular values* | ||
2. Receiving elements must be `animated.[elementName]`, for instance `div` becomes `animated.div` | ||
@@ -136,3 +144,3 @@ 3. If you need to interpolate styles use the `template` string literal | ||
You can use this prototype for two-state reveals, in that case simply render a single child that you can switch out for another. | ||
You can use this prototype for two-state reveals, simply render a single child that you can switch out for another. | ||
@@ -152,7 +160,7 @@ | ||
# Trails/Staggered transitions 👣 | ||
# Trails/Staggered transitions 🐾🐾🐾 | ||
([Demo](https://codesandbox.io/embed/vvmv6x01l5)) | ||
Create trailing animations by using SpringTrail. The api is similar to SpringTransition though it will assume your list is fixed. The items will drop in in a trailing motion. | ||
Create trailing animations by using `SpringTrail`. The api is similar to `SpringTransition` though it will assume your list is fixed. The items will interpolate in a staggered fashion, internally one spring follows the interpolated value of the previous one thereby creating a staggered chain. | ||
@@ -172,1 +180,5 @@ ```jsx | ||
``` | ||
--- | ||
[API](https://github.com/drcmda/react-spring/blob/master/API.md) | [Changelog](https://github.com/drcmda/react-spring/blob/master/CHANGELOG.md) |
import Animated from './Animated' | ||
import AnimatedWithChildren from './AnimatedWithChildren' | ||
import invariant from 'invariant' | ||
import Interpolation from './Interpolation' | ||
@@ -17,4 +16,2 @@ import guid from './guid' | ||
const parentValue = this._parent.__getValue() | ||
invariant(typeof parentValue === 'number', 'Cannot interpolate an input which is not a number.') | ||
return this._interpolation(parentValue) | ||
@@ -21,0 +18,0 @@ } |
@@ -7,3 +7,2 @@ import Animated from './Animated' | ||
super() | ||
if (props.style) { | ||
@@ -15,6 +14,4 @@ props = { | ||
} | ||
this._props = props | ||
this._callback = callback | ||
this.__attach() | ||
@@ -25,11 +22,6 @@ } | ||
const props = {} | ||
for (const key in this._props) { | ||
const value = this._props[key] | ||
if (value instanceof Animated) { | ||
props[key] = value.__getValue() | ||
} else { | ||
props[key] = value | ||
} | ||
if (value instanceof Animated) props[key] = value.__getValue() | ||
else props[key] = value | ||
} | ||
@@ -42,11 +34,6 @@ | ||
const props = {} | ||
for (const key in this._props) { | ||
const value = this._props[key] | ||
if (value instanceof Animated) { | ||
props[key] = value.__getAnimatedValue() | ||
} | ||
if (value instanceof Animated) props[key] = value.__getAnimatedValue() | ||
} | ||
return props | ||
@@ -58,6 +45,3 @@ } | ||
const value = this._props[key] | ||
if (value instanceof Animated) { | ||
value.__addChild(this) | ||
} | ||
if (value instanceof Animated) value.__addChild(this) | ||
} | ||
@@ -69,6 +53,3 @@ } | ||
const value = this._props[key] | ||
if (value instanceof Animated) { | ||
value.__removeChild(this) | ||
} | ||
if (value instanceof Animated) value.__removeChild(this) | ||
} | ||
@@ -75,0 +56,0 @@ } |
@@ -14,11 +14,6 @@ import Animated from './Animated' | ||
const style = {} | ||
for (const key in this._style) { | ||
const value = this._style[key] | ||
if (value instanceof Animated) { | ||
style[key] = value.__getValue() | ||
} else { | ||
style[key] = value | ||
} | ||
if (value instanceof Animated) style[key] = value.__getValue() | ||
else style[key] = value | ||
} | ||
@@ -31,11 +26,6 @@ | ||
const style = {} | ||
for (const key in this._style) { | ||
const value = this._style[key] | ||
if (value instanceof Animated) { | ||
style[key] = value.__getAnimatedValue() | ||
} | ||
if (value instanceof Animated) style[key] = value.__getAnimatedValue() | ||
} | ||
return style | ||
@@ -47,6 +37,3 @@ } | ||
const value = this._style[key] | ||
if (value instanceof Animated) { | ||
value.__addChild(this) | ||
} | ||
if (value instanceof Animated) value.__addChild(this) | ||
} | ||
@@ -58,6 +45,3 @@ } | ||
const value = this._style[key] | ||
if (value instanceof Animated) { | ||
value.__removeChild(this) | ||
} | ||
if (value instanceof Animated) value.__removeChild(this) | ||
} | ||
@@ -64,0 +48,0 @@ } |
@@ -12,7 +12,4 @@ import Animated from './Animated' | ||
__transformValue(value) { | ||
if (value instanceof Animated) { | ||
return value.__getValue() | ||
} else { | ||
return value | ||
} | ||
if (value instanceof Animated) return value.__getValue() | ||
else return value | ||
} | ||
@@ -22,7 +19,5 @@ | ||
let value = this._strings[0] | ||
for (let i = 0; i < this._values.length; ++i) { | ||
value += this.__transformValue(this._values[i]) + this._strings[1 + i] | ||
} | ||
return value | ||
@@ -33,5 +28,3 @@ } | ||
for (let i = 0; i < this._values.length; ++i) { | ||
if (this._values[i] instanceof Animated) { | ||
this._values[i].__addChild(this) | ||
} | ||
if (this._values[i] instanceof Animated) this._values[i].__addChild(this) | ||
} | ||
@@ -42,5 +35,3 @@ } | ||
for (let i = 0; i < this._values.length; ++i) { | ||
if (this._values[i] instanceof Animated) { | ||
this._values[i].__removeChild(this) | ||
} | ||
if (this._values[i] instanceof Animated) this._values[i].__removeChild(this) | ||
} | ||
@@ -47,0 +38,0 @@ } |
@@ -12,3 +12,2 @@ import Animated from './Animated' | ||
this._callback = callback | ||
this.__attach() | ||
@@ -15,0 +14,0 @@ } |
@@ -145,7 +145,3 @@ import AnimatedWithChildren from './AnimatedWithChildren' | ||
var handle = null | ||
if (animation.__isInteraction) { | ||
handle = InteractionManager.current.createInteractionHandle() | ||
} | ||
if (animation.__isInteraction) handle = InteractionManager.current.createInteractionHandle() | ||
var previousAnimation = this._animation | ||
@@ -156,12 +152,6 @@ this._animation && this._animation.stop() | ||
this._value, | ||
value => { | ||
this._updateValue(value) | ||
}, | ||
value => this._updateValue(value), | ||
result => { | ||
this._animation = null | ||
if (handle !== null) { | ||
InteractionManager.current.clearInteractionHandle(handle) | ||
} | ||
if (handle !== null) InteractionManager.current.clearInteractionHandle(handle) | ||
callback && callback(result) | ||
@@ -191,5 +181,3 @@ }, | ||
this._value = value | ||
_flush(this) | ||
for (var key in this._listeners) { | ||
@@ -196,0 +184,0 @@ this._listeners[key]({ |
@@ -10,6 +10,3 @@ import Animated from './Animated' | ||
__addChild(child) { | ||
if (this._children.length === 0) { | ||
this.__attach() | ||
} | ||
if (this._children.length === 0) this.__attach() | ||
this._children.push(child) | ||
@@ -20,3 +17,2 @@ } | ||
const index = this._children.indexOf(child) | ||
if (index === -1) { | ||
@@ -26,8 +22,4 @@ console.warn("Trying to remove a child that doesn't exist") | ||
} | ||
this._children.splice(index, 1) | ||
if (this._children.length === 0) { | ||
this.__detach() | ||
} | ||
if (this._children.length === 0) this.__detach() | ||
} | ||
@@ -34,0 +26,0 @@ |
@@ -13,6 +13,3 @@ import React from 'react' | ||
var didUpdate = this.refName && ApplyAnimatedValues.current(this.refName, props, this) | ||
if (!didUpdate) { | ||
this.forceUpdate() | ||
} | ||
if (!didUpdate) this.forceUpdate() | ||
} | ||
@@ -38,5 +35,3 @@ | ||
if (!didUpdate) { | ||
this.forceUpdate() | ||
} | ||
if (!didUpdate) this.forceUpdate() | ||
} | ||
@@ -69,5 +64,4 @@ | ||
style: function(props, propName, componentName) { | ||
if (!Component.propTypes) { | ||
return | ||
} // TODO(lmr): We will probably bring this back in at some point, but maybe | ||
if (!Component.propTypes) return | ||
// TODO(lmr): We will probably bring this back in at some point, but maybe | ||
// just a subset of the proptypes... We should have a common set of props | ||
@@ -74,0 +68,0 @@ // that will be used for all platforms. |
@@ -1,4 +0,4 @@ | ||
import invariant from 'invariant' | ||
import Animated from './Animated' | ||
import AnimatedValue from './AnimatedValue' | ||
import AnimatedArray from './AnimatedArray' | ||
import Animation from './Animation' | ||
@@ -16,21 +16,66 @@ import AnimatedTemplate from './AnimatedTemplate' | ||
const maybeVectorAnim = (array, { tension, friction, toValue }, anim) => { | ||
// { tension, friction, toValue: [...]} | ||
if (array instanceof AnimatedArray) | ||
return parallel(array.values.map((v, i) => anim(v, { tension, friction, toValue: toValue[i] })), { | ||
stopTogether: false, | ||
}) | ||
return null | ||
} | ||
var spring = function(value, config) { | ||
return { | ||
start: function(callback) { | ||
var singleValue = value | ||
var singleConfig = config | ||
//singleValue.stopTracking() | ||
return ( | ||
maybeVectorAnim(value, config, spring) || { | ||
start: function(callback) { | ||
var singleValue = value | ||
var singleConfig = config | ||
singleValue.stopTracking() | ||
if (config.toValue instanceof Animated) { | ||
singleValue.track( | ||
new AnimatedTracking(singleValue, config.toValue, SpringAnimation, singleConfig, callback), | ||
) | ||
} else { | ||
singleValue.animate(new SpringAnimation(singleConfig), callback) | ||
} | ||
}, | ||
stop: function() { | ||
value.stopAnimation() | ||
}, | ||
} | ||
) | ||
} | ||
if (config.toValue instanceof Animated) { | ||
singleValue.track( | ||
new AnimatedTracking(singleValue, config.toValue, SpringAnimation, singleConfig, callback), | ||
) | ||
} else { | ||
singleValue.animate(new SpringAnimation(singleConfig), callback) | ||
var parallel = (animations, config) => { | ||
let doneCount = 0 | ||
const hasEnded = {} | ||
const stopTogether = !(config && config.stopTogether === false) | ||
const result = { | ||
start(callback) { | ||
if (doneCount === animations.length) { | ||
callback && callback({ finished: true }) | ||
return | ||
} | ||
animations.forEach((animation, idx) => { | ||
const cb = endResult => { | ||
hasEnded[idx] = true | ||
doneCount++ | ||
if (doneCount === animations.length) { | ||
doneCount = 0 | ||
callback && callback(endResult) | ||
return | ||
} | ||
if (!endResult.finished && stopTogether) result.stop() | ||
} | ||
if (!animation) cb({ finished: true }) | ||
else animation.start(cb) | ||
}) | ||
}, | ||
stop: function() { | ||
value.stopAnimation() | ||
stop() { | ||
animations.forEach((animation, idx) => { | ||
!hasEnded[idx] && animation.stop() | ||
hasEnded[idx] = true | ||
}) | ||
}, | ||
} | ||
return result | ||
} | ||
@@ -40,2 +85,3 @@ | ||
Value: AnimatedValue, | ||
Array: AnimatedArray, | ||
spring, | ||
@@ -42,0 +88,0 @@ template: function template(strings, ...values) { |
import normalizeColor from 'normalize-css-color' | ||
import invariant from 'invariant' | ||
@@ -15,16 +14,4 @@ var linear = t => t | ||
} | ||
var outputRange = config.outputRange | ||
checkInfiniteRange('outputRange', outputRange) | ||
var inputRange = config.inputRange | ||
checkInfiniteRange('inputRange', inputRange) | ||
checkValidInputRange(inputRange) | ||
invariant( | ||
inputRange.length === outputRange.length, | ||
'inputRange (' + | ||
inputRange.length + | ||
') and outputRange (' + | ||
outputRange.length + | ||
') must have the same length', | ||
) | ||
var easing = config.easing || linear | ||
@@ -48,3 +35,2 @@ var extrapolateLeft = 'extend' | ||
return input => { | ||
invariant(typeof input === 'number', 'Cannot interpolation an input which is not a number') | ||
var range = findRange(input, inputRange) | ||
@@ -149,5 +135,3 @@ return interpolate( | ||
var outputRange = config.outputRange | ||
invariant(outputRange.length >= 2, 'Bad output range') | ||
outputRange = outputRange.map(colorToRgba) | ||
checkPattern(outputRange) // ['rgba(0, 100, 200, 0)', 'rgba(50, 150, 250, 0.5)'] | ||
// -> | ||
@@ -191,3 +175,2 @@ // [ | ||
// 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...' | ||
return outputRange[0].replace(stringShapeRegex, () => { | ||
@@ -200,51 +183,9 @@ const val = interpolations[i++](input) | ||
function checkPattern(arr) { | ||
var pattern = arr[0].replace(stringShapeRegex, '') | ||
for (var i = 1; i < arr.length; ++i) { | ||
invariant(pattern === arr[i].replace(stringShapeRegex, ''), 'invalid pattern ' + arr[0] + ' and ' + arr[i]) | ||
} | ||
} | ||
function findRange(input, inputRange) { | ||
for (var i = 1; i < inputRange.length - 1; ++i) { | ||
if (inputRange[i] >= input) { | ||
break | ||
} | ||
if (inputRange[i] >= input) break | ||
} | ||
return i - 1 | ||
} | ||
function checkValidInputRange(arr) { | ||
invariant(arr.length >= 2, 'inputRange must have at least 2 elements') | ||
for (var i = 1; i < arr.length; ++i) { | ||
invariant( | ||
arr[i] >= arr[i - 1], | ||
/* $FlowFixMe(>=0.13.0) - In the addition expression below this comment, | ||
* one or both of the operands may be something that doesn't cleanly | ||
* convert to a string, like undefined, null, and object, etc. If you really | ||
* mean this implicit string conversion, you can do something like | ||
* String(myThing) | ||
*/ | ||
'inputRange must be monotonically increasing ' + arr, | ||
) | ||
} | ||
} | ||
function checkInfiniteRange(name, arr) { | ||
invariant(arr.length >= 2, name + ' must have at least 2 elements') | ||
invariant( | ||
arr.length !== 2 || arr[0] !== -Infinity || arr[1] !== Infinity, | ||
/* $FlowFixMe(>=0.13.0) - In the addition expression below this comment, | ||
* one or both of the operands may be something that doesn't cleanly convert | ||
* to a string, like undefined, null, and object, etc. If you really mean | ||
* this implicit string conversion, you can do something like | ||
* String(myThing) | ||
*/ | ||
name + 'cannot be ]-infinity;+infinity[ ' + arr, | ||
) | ||
} | ||
export default Interpolation |
@@ -5,3 +5,2 @@ import Animation from './Animation' | ||
import CancelAnimationFrame from './injectable/CancelAnimationFrame' | ||
import invariant from 'invariant' | ||
import SpringConfig from './SpringConfig' | ||
@@ -8,0 +7,0 @@ |
@@ -43,4 +43,5 @@ import React from 'react' | ||
let isNumber = typeof value === 'number' | ||
let isArray = !isNumber && Array.isArray(value) | ||
let fromValue = from[name] !== undefined ? from[name] : value | ||
let toValue = isNumber ? value : 1 | ||
let toValue = isNumber || isArray ? value : 1 | ||
@@ -57,2 +58,5 @@ if (isNumber && attach) { | ||
entry.animation = entry.interpolation = entry.animation || new Animated.Value(fromValue) | ||
} else if (isArray) { | ||
// Create animated array | ||
entry.animation = entry.interpolation = entry.animation || new Animated.Array(fromValue) | ||
} else { | ||
@@ -108,3 +112,3 @@ // Deal with interpolations | ||
const Animation = createAnimation(interpolator, defaultConfig) | ||
return class SpringTransition extends React.PureComponent { | ||
return class extends React.PureComponent { | ||
static propTypes = { | ||
@@ -129,3 +133,3 @@ native: PropTypes.bool, | ||
let { children, render, keys, from, enter, leave } = props | ||
children = render || children | ||
children = render || children | ||
if (!Array.isArray(children)) children = [children] | ||
@@ -142,3 +146,3 @@ if (!Array.isArray(keys)) keys = [keys] | ||
let { children, render, keys, from, enter, leave } = props | ||
children = render || children | ||
children = render || children | ||
if (!Array.isArray(children)) children = [children] | ||
@@ -211,6 +215,9 @@ if (!Array.isArray(keys)) keys = [keys] | ||
const props = { native, config, ...extra } | ||
return this.state.transitions.map(({ key, children, ...rest }) => | ||
render | ||
? <Animation key={key} {...rest} {...props} render={children} children={this.props.children} /> | ||
: <Animation key={key} {...rest} {...props} children={children} /> | ||
return this.state.transitions.map( | ||
({ key, children, ...rest }) => | ||
render ? ( | ||
<Animation key={key} {...rest} {...props} render={children} children={this.props.children} /> | ||
) : ( | ||
<Animation key={key} {...rest} {...props} children={children} /> | ||
), | ||
) | ||
@@ -223,3 +230,3 @@ } | ||
const Animation = createAnimation(interpolator, defaultConfig) | ||
return class SpringTrail extends React.PureComponent { | ||
return class extends React.PureComponent { | ||
static propTypes = { | ||
@@ -246,5 +253,7 @@ native: PropTypes.bool, | ||
const attachedHook = animation => hook(i, animation) | ||
return render | ||
? <Animation key={keys[i]} {...props} attach={attachedHook} render={child} children={children} /> | ||
: <Animation key={keys[i]} {...props} attach={attachedHook} children={child} /> | ||
return render ? ( | ||
<Animation key={keys[i]} {...props} attach={attachedHook} render={child} children={children} /> | ||
) : ( | ||
<Animation key={keys[i]} {...props} attach={attachedHook} children={child} /> | ||
) | ||
}) | ||
@@ -251,0 +260,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193006
4
36
1716
179
- Removedinvariant@^2.2.3
- Removedinvariant@2.2.4(transitive)