ab83085cfca8e06acd8e973641e56d48.json 25.6 KB
{"ast":null,"code":"'use strict';var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.default=void 0;var _AnimatedValue=_interopRequireDefault(require(\"../nodes/AnimatedValue\"));var _AnimatedValueXY=_interopRequireDefault(require(\"../nodes/AnimatedValueXY\"));var _Animation2=_interopRequireDefault(require(\"./Animation\"));var _SpringConfig=_interopRequireDefault(require(\"../SpringConfig\"));var _invariant=_interopRequireDefault(require(\"fbjs/lib/invariant\"));var _NativeAnimatedHelper=require(\"../NativeAnimatedHelper\");function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;subClass.__proto__=superClass;}function withDefault(value,defaultValue){if(value===undefined||value===null){return defaultValue;}return value;}var SpringAnimation=function(_Animation){_inheritsLoose(SpringAnimation,_Animation);function SpringAnimation(config){var _this;_this=_Animation.call(this)||this;_this._overshootClamping=withDefault(config.overshootClamping,false);_this._restDisplacementThreshold=withDefault(config.restDisplacementThreshold,0.001);_this._restSpeedThreshold=withDefault(config.restSpeedThreshold,0.001);_this._initialVelocity=withDefault(config.velocity,0);_this._lastVelocity=withDefault(config.velocity,0);_this._toValue=config.toValue;_this._delay=withDefault(config.delay,0);_this._useNativeDriver=(0,_NativeAnimatedHelper.shouldUseNativeDriver)(config);_this.__isInteraction=config.isInteraction!==undefined?config.isInteraction:true;_this.__iterations=config.iterations!==undefined?config.iterations:1;if(config.stiffness!==undefined||config.damping!==undefined||config.mass!==undefined){(0,_invariant.default)(config.bounciness===undefined&&config.speed===undefined&&config.tension===undefined&&config.friction===undefined,'You can define one of bounciness/speed, tension/friction, or stiffness/damping/mass, but not more than one');_this._stiffness=withDefault(config.stiffness,100);_this._damping=withDefault(config.damping,10);_this._mass=withDefault(config.mass,1);}else if(config.bounciness!==undefined||config.speed!==undefined){(0,_invariant.default)(config.tension===undefined&&config.friction===undefined&&config.stiffness===undefined&&config.damping===undefined&&config.mass===undefined,'You can define one of bounciness/speed, tension/friction, or stiffness/damping/mass, but not more than one');var springConfig=_SpringConfig.default.fromBouncinessAndSpeed(withDefault(config.bounciness,8),withDefault(config.speed,12));_this._stiffness=springConfig.stiffness;_this._damping=springConfig.damping;_this._mass=1;}else{var _springConfig=_SpringConfig.default.fromOrigamiTensionAndFriction(withDefault(config.tension,40),withDefault(config.friction,7));_this._stiffness=_springConfig.stiffness;_this._damping=_springConfig.damping;_this._mass=1;}(0,_invariant.default)(_this._stiffness>0,'Stiffness value must be greater than 0');(0,_invariant.default)(_this._damping>0,'Damping value must be greater than 0');(0,_invariant.default)(_this._mass>0,'Mass value must be greater than 0');return _this;}var _proto=SpringAnimation.prototype;_proto.__getNativeAnimationConfig=function __getNativeAnimationConfig(){return{type:'spring',overshootClamping:this._overshootClamping,restDisplacementThreshold:this._restDisplacementThreshold,restSpeedThreshold:this._restSpeedThreshold,stiffness:this._stiffness,damping:this._damping,mass:this._mass,initialVelocity:withDefault(this._initialVelocity,this._lastVelocity),toValue:this._toValue,iterations:this.__iterations};};_proto.start=function start(fromValue,onUpdate,onEnd,previousAnimation,animatedValue){var _this2=this;this.__active=true;this._startPosition=fromValue;this._lastPosition=this._startPosition;this._onUpdate=onUpdate;this.__onEnd=onEnd;this._lastTime=Date.now();this._frameTime=0.0;if(previousAnimation instanceof SpringAnimation){var internalState=previousAnimation.getInternalState();this._lastPosition=internalState.lastPosition;this._lastVelocity=internalState.lastVelocity;this._initialVelocity=this._lastVelocity;this._lastTime=internalState.lastTime;}var start=function start(){if(_this2._useNativeDriver){_this2.__startNativeAnimation(animatedValue);}else{_this2.onUpdate();}};if(this._delay){this._timeout=setTimeout(start,this._delay);}else{start();}};_proto.getInternalState=function getInternalState(){return{lastPosition:this._lastPosition,lastVelocity:this._lastVelocity,lastTime:this._lastTime};};_proto.onUpdate=function onUpdate(){var MAX_STEPS=64;var now=Date.now();if(now>this._lastTime+MAX_STEPS){now=this._lastTime+MAX_STEPS;}var deltaTime=(now-this._lastTime)/1000;this._frameTime+=deltaTime;var c=this._damping;var m=this._mass;var k=this._stiffness;var v0=-this._initialVelocity;var zeta=c/(2*Math.sqrt(k*m));var omega0=Math.sqrt(k/m);var omega1=omega0*Math.sqrt(1.0-zeta*zeta);var x0=this._toValue-this._startPosition;var position=0.0;var velocity=0.0;var t=this._frameTime;if(zeta<1){var envelope=Math.exp(-zeta*omega0*t);position=this._toValue-envelope*((v0+zeta*omega0*x0)/omega1*Math.sin(omega1*t)+x0*Math.cos(omega1*t));velocity=zeta*omega0*envelope*(Math.sin(omega1*t)*(v0+zeta*omega0*x0)/omega1+x0*Math.cos(omega1*t))-envelope*(Math.cos(omega1*t)*(v0+zeta*omega0*x0)-omega1*x0*Math.sin(omega1*t));}else{var _envelope=Math.exp(-omega0*t);position=this._toValue-_envelope*(x0+(v0+omega0*x0)*t);velocity=_envelope*(v0*(t*omega0-1)+t*x0*(omega0*omega0));}this._lastTime=now;this._lastPosition=position;this._lastVelocity=velocity;this._onUpdate(position);if(!this.__active){return;}var isOvershooting=false;if(this._overshootClamping&&this._stiffness!==0){if(this._startPosition<this._toValue){isOvershooting=position>this._toValue;}else{isOvershooting=position<this._toValue;}}var isVelocity=Math.abs(velocity)<=this._restSpeedThreshold;var isDisplacement=true;if(this._stiffness!==0){isDisplacement=Math.abs(this._toValue-position)<=this._restDisplacementThreshold;}if(isOvershooting||isVelocity&&isDisplacement){if(this._stiffness!==0){this._lastPosition=this._toValue;this._lastVelocity=0;this._onUpdate(this._toValue);}this.__debouncedOnEnd({finished:true});return;}this._animationFrame=requestAnimationFrame(this.onUpdate.bind(this));};_proto.stop=function stop(){_Animation.prototype.stop.call(this);this.__active=false;clearTimeout(this._timeout);global.cancelAnimationFrame(this._animationFrame);this.__debouncedOnEnd({finished:false});};return SpringAnimation;}(_Animation2.default);var _default=SpringAnimation;exports.default=_default;","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-web/dist/vendor/react-native/Animated/animations/SpringAnimation.js"],"names":["_inheritsLoose","subClass","superClass","prototype","Object","create","constructor","__proto__","withDefault","value","defaultValue","undefined","SpringAnimation","_Animation","config","_this","call","_overshootClamping","overshootClamping","_restDisplacementThreshold","restDisplacementThreshold","_restSpeedThreshold","restSpeedThreshold","_initialVelocity","velocity","_lastVelocity","_toValue","toValue","_delay","delay","_useNativeDriver","__isInteraction","isInteraction","__iterations","iterations","stiffness","damping","mass","bounciness","speed","tension","friction","_stiffness","_damping","_mass","springConfig","SpringConfig","fromBouncinessAndSpeed","_springConfig","fromOrigamiTensionAndFriction","_proto","__getNativeAnimationConfig","type","initialVelocity","start","fromValue","onUpdate","onEnd","previousAnimation","animatedValue","_this2","__active","_startPosition","_lastPosition","_onUpdate","__onEnd","_lastTime","Date","now","_frameTime","internalState","getInternalState","lastPosition","lastVelocity","lastTime","__startNativeAnimation","_timeout","setTimeout","MAX_STEPS","deltaTime","c","m","k","v0","zeta","Math","sqrt","omega0","omega1","x0","position","t","envelope","exp","sin","cos","_envelope","isOvershooting","isVelocity","abs","isDisplacement","__debouncedOnEnd","finished","_animationFrame","requestAnimationFrame","bind","stop","clearTimeout","global","cancelAnimationFrame","Animation"],"mappings":"AASA,a,mKAIA,6EACA,iFACA,+DACA,qEACA,qEACA,6DAPA,QAASA,CAAAA,cAAT,CAAwBC,QAAxB,CAAkCC,UAAlC,CAA8C,CAAED,QAAQ,CAACE,SAAT,CAAqBC,MAAM,CAACC,MAAP,CAAcH,UAAU,CAACC,SAAzB,CAArB,CAA0DF,QAAQ,CAACE,SAAT,CAAmBG,WAAnB,CAAiCL,QAAjC,CAA2CA,QAAQ,CAACM,SAAT,CAAqBL,UAArB,CAAkC,CASvL,QAASM,CAAAA,WAAT,CAAqBC,KAArB,CAA4BC,YAA5B,CAA0C,CACxC,GAAID,KAAK,GAAKE,SAAV,EAAuBF,KAAK,GAAK,IAArC,CAA2C,CACzC,MAAOC,CAAAA,YAAP,CACD,C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AsB,CACpBC,QAAQ,CAAE,KADU,CAAtB,EAGD,CAVD,CAYA,MAAO1F,CAAAA,eAAP,CACD,CA7OD,CA6OEkG,mBA7OF,CAFA,C,aAiPelG,e","sourcesContent":["/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n * @format\n */\n'use strict';\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nimport AnimatedValue from '../nodes/AnimatedValue';\nimport AnimatedValueXY from '../nodes/AnimatedValueXY';\nimport Animation from './Animation';\nimport SpringConfig from '../SpringConfig';\nimport invariant from 'fbjs/lib/invariant';\nimport { shouldUseNativeDriver } from '../NativeAnimatedHelper';\n\nfunction withDefault(value, defaultValue) {\n  if (value === undefined || value === null) {\n    return defaultValue;\n  }\n\n  return value;\n}\n\nvar SpringAnimation =\n/*#__PURE__*/\nfunction (_Animation) {\n  _inheritsLoose(SpringAnimation, _Animation);\n\n  function SpringAnimation(config) {\n    var _this;\n\n    _this = _Animation.call(this) || this;\n    _this._overshootClamping = withDefault(config.overshootClamping, false);\n    _this._restDisplacementThreshold = withDefault(config.restDisplacementThreshold, 0.001);\n    _this._restSpeedThreshold = withDefault(config.restSpeedThreshold, 0.001);\n    _this._initialVelocity = withDefault(config.velocity, 0);\n    _this._lastVelocity = withDefault(config.velocity, 0);\n    _this._toValue = config.toValue;\n    _this._delay = withDefault(config.delay, 0);\n    _this._useNativeDriver = shouldUseNativeDriver(config);\n    _this.__isInteraction = config.isInteraction !== undefined ? config.isInteraction : true;\n    _this.__iterations = config.iterations !== undefined ? config.iterations : 1;\n\n    if (config.stiffness !== undefined || config.damping !== undefined || config.mass !== undefined) {\n      invariant(config.bounciness === undefined && config.speed === undefined && config.tension === undefined && config.friction === undefined, 'You can define one of bounciness/speed, tension/friction, or stiffness/damping/mass, but not more than one');\n      _this._stiffness = withDefault(config.stiffness, 100);\n      _this._damping = withDefault(config.damping, 10);\n      _this._mass = withDefault(config.mass, 1);\n    } else if (config.bounciness !== undefined || config.speed !== undefined) {\n      // Convert the origami bounciness/speed values to stiffness/damping\n      // We assume mass is 1.\n      invariant(config.tension === undefined && config.friction === undefined && config.stiffness === undefined && config.damping === undefined && config.mass === undefined, 'You can define one of bounciness/speed, tension/friction, or stiffness/damping/mass, but not more than one');\n      var springConfig = SpringConfig.fromBouncinessAndSpeed(withDefault(config.bounciness, 8), withDefault(config.speed, 12));\n      _this._stiffness = springConfig.stiffness;\n      _this._damping = springConfig.damping;\n      _this._mass = 1;\n    } else {\n      // Convert the origami tension/friction values to stiffness/damping\n      // We assume mass is 1.\n      var _springConfig = SpringConfig.fromOrigamiTensionAndFriction(withDefault(config.tension, 40), withDefault(config.friction, 7));\n\n      _this._stiffness = _springConfig.stiffness;\n      _this._damping = _springConfig.damping;\n      _this._mass = 1;\n    }\n\n    invariant(_this._stiffness > 0, 'Stiffness value must be greater than 0');\n    invariant(_this._damping > 0, 'Damping value must be greater than 0');\n    invariant(_this._mass > 0, 'Mass value must be greater than 0');\n    return _this;\n  }\n\n  var _proto = SpringAnimation.prototype;\n\n  _proto.__getNativeAnimationConfig = function __getNativeAnimationConfig() {\n    return {\n      type: 'spring',\n      overshootClamping: this._overshootClamping,\n      restDisplacementThreshold: this._restDisplacementThreshold,\n      restSpeedThreshold: this._restSpeedThreshold,\n      stiffness: this._stiffness,\n      damping: this._damping,\n      mass: this._mass,\n      initialVelocity: withDefault(this._initialVelocity, this._lastVelocity),\n      toValue: this._toValue,\n      iterations: this.__iterations\n    };\n  };\n\n  _proto.start = function start(fromValue, onUpdate, onEnd, previousAnimation, animatedValue) {\n    var _this2 = this;\n\n    this.__active = true;\n    this._startPosition = fromValue;\n    this._lastPosition = this._startPosition;\n    this._onUpdate = onUpdate;\n    this.__onEnd = onEnd;\n    this._lastTime = Date.now();\n    this._frameTime = 0.0;\n\n    if (previousAnimation instanceof SpringAnimation) {\n      var internalState = previousAnimation.getInternalState();\n      this._lastPosition = internalState.lastPosition;\n      this._lastVelocity = internalState.lastVelocity; // Set the initial velocity to the last velocity\n\n      this._initialVelocity = this._lastVelocity;\n      this._lastTime = internalState.lastTime;\n    }\n\n    var start = function start() {\n      if (_this2._useNativeDriver) {\n        _this2.__startNativeAnimation(animatedValue);\n      } else {\n        _this2.onUpdate();\n      }\n    }; //  If this._delay is more than 0, we start after the timeout.\n\n\n    if (this._delay) {\n      this._timeout = setTimeout(start, this._delay);\n    } else {\n      start();\n    }\n  };\n\n  _proto.getInternalState = function getInternalState() {\n    return {\n      lastPosition: this._lastPosition,\n      lastVelocity: this._lastVelocity,\n      lastTime: this._lastTime\n    };\n  }\n  /**\n   * This spring model is based off of a damped harmonic oscillator\n   * (https://en.wikipedia.org/wiki/Harmonic_oscillator#Damped_harmonic_oscillator).\n   *\n   * We use the closed form of the second order differential equation:\n   *\n   * x'' + (2ζ⍵_0)x' + ⍵^2x = 0\n   *\n   * where\n   *    ⍵_0 = √(k / m) (undamped angular frequency of the oscillator),\n   *    ζ = c / 2√mk (damping ratio),\n   *    c = damping constant\n   *    k = stiffness\n   *    m = mass\n   *\n   * The derivation of the closed form is described in detail here:\n   * http://planetmath.org/sites/default/files/texpdf/39745.pdf\n   *\n   * This algorithm happens to match the algorithm used by CASpringAnimation,\n   * a QuartzCore (iOS) API that creates spring animations.\n   */\n  ;\n\n  _proto.onUpdate = function onUpdate() {\n    // If for some reason we lost a lot of frames (e.g. process large payload or\n    // stopped in the debugger), we only advance by 4 frames worth of\n    // computation and will continue on the next frame. It's better to have it\n    // running at faster speed than jumping to the end.\n    var MAX_STEPS = 64;\n    var now = Date.now();\n\n    if (now > this._lastTime + MAX_STEPS) {\n      now = this._lastTime + MAX_STEPS;\n    }\n\n    var deltaTime = (now - this._lastTime) / 1000;\n    this._frameTime += deltaTime;\n    var c = this._damping;\n    var m = this._mass;\n    var k = this._stiffness;\n    var v0 = -this._initialVelocity;\n    var zeta = c / (2 * Math.sqrt(k * m)); // damping ratio\n\n    var omega0 = Math.sqrt(k / m); // undamped angular frequency of the oscillator (rad/ms)\n\n    var omega1 = omega0 * Math.sqrt(1.0 - zeta * zeta); // exponential decay\n\n    var x0 = this._toValue - this._startPosition; // calculate the oscillation from x0 = 1 to x = 0\n\n    var position = 0.0;\n    var velocity = 0.0;\n    var t = this._frameTime;\n\n    if (zeta < 1) {\n      // Under damped\n      var envelope = Math.exp(-zeta * omega0 * t);\n      position = this._toValue - envelope * ((v0 + zeta * omega0 * x0) / omega1 * Math.sin(omega1 * t) + x0 * Math.cos(omega1 * t)); // This looks crazy -- it's actually just the derivative of the\n      // oscillation function\n\n      velocity = zeta * omega0 * envelope * (Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0) / omega1 + x0 * Math.cos(omega1 * t)) - envelope * (Math.cos(omega1 * t) * (v0 + zeta * omega0 * x0) - omega1 * x0 * Math.sin(omega1 * t));\n    } else {\n      // Critically damped\n      var _envelope = Math.exp(-omega0 * t);\n\n      position = this._toValue - _envelope * (x0 + (v0 + omega0 * x0) * t);\n      velocity = _envelope * (v0 * (t * omega0 - 1) + t * x0 * (omega0 * omega0));\n    }\n\n    this._lastTime = now;\n    this._lastPosition = position;\n    this._lastVelocity = velocity;\n\n    this._onUpdate(position);\n\n    if (!this.__active) {\n      // a listener might have stopped us in _onUpdate\n      return;\n    } // Conditions for stopping the spring animation\n\n\n    var isOvershooting = false;\n\n    if (this._overshootClamping && this._stiffness !== 0) {\n      if (this._startPosition < this._toValue) {\n        isOvershooting = position > this._toValue;\n      } else {\n        isOvershooting = position < this._toValue;\n      }\n    }\n\n    var isVelocity = Math.abs(velocity) <= this._restSpeedThreshold;\n\n    var isDisplacement = true;\n\n    if (this._stiffness !== 0) {\n      isDisplacement = Math.abs(this._toValue - position) <= this._restDisplacementThreshold;\n    }\n\n    if (isOvershooting || isVelocity && isDisplacement) {\n      if (this._stiffness !== 0) {\n        // Ensure that we end up with a round value\n        this._lastPosition = this._toValue;\n        this._lastVelocity = 0;\n\n        this._onUpdate(this._toValue);\n      }\n\n      this.__debouncedOnEnd({\n        finished: true\n      });\n\n      return;\n    }\n\n    this._animationFrame = requestAnimationFrame(this.onUpdate.bind(this));\n  };\n\n  _proto.stop = function stop() {\n    _Animation.prototype.stop.call(this);\n\n    this.__active = false;\n    clearTimeout(this._timeout);\n    global.cancelAnimationFrame(this._animationFrame);\n\n    this.__debouncedOnEnd({\n      finished: false\n    });\n  };\n\n  return SpringAnimation;\n}(Animation);\n\nexport default SpringAnimation;"]},"metadata":{},"sourceType":"script"}