294c71841bcc5c16c2def5c63dfe1f6a.json 8.5 KB
{"ast":null,"code":"var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.default=backwardsCompatibleAnimWrapper;var _base=require(\"../base\");var _AnimatedClock=_interopRequireDefault(require(\"../core/AnimatedClock\"));var _evaluateOnce=require(\"../derived/evaluateOnce\");function createOldAnimationObject(node,AnimationClass,value,config){var newClock=new _AnimatedClock.default();var currentState=AnimationClass.getDefaultState();var alwaysNode;var isStarted=false;var isDone=false;var wasStopped=false;var animationCallback;var animation={start:function start(currentAnimationCallback){animationCallback=currentAnimationCallback;if(isStarted){animationCallback&&animationCallback({finished:false});return;}if(isDone){console.warn('Animation has been finished before');return;}if(!value.isNativelyInitialized()){return;}isStarted=true;(0,_evaluateOnce.evaluateOnce)((0,_base.set)(currentState.position,value),currentState.position,function(){alwaysNode=(0,_base.always)((0,_base.set)(value,(0,_base.block)([(0,_base.cond)((0,_base.clockRunning)(newClock),0,(0,_base.startClock)(newClock)),node(newClock,currentState,config),(0,_base.cond)(currentState.finished,[(0,_base.call)([],function(){isStarted=false;if(!wasStopped){isDone=true;}value.__detachAnimation(animation);isDone=true;if(!wasStopped){wasStopped=false;}}),(0,_base.stopClock)(newClock)]),currentState.position])));value.__attachAnimation(animation);alwaysNode.__addChild(value);});},__detach:function __detach(){animationCallback&&animationCallback({finished:isDone});animationCallback=null;alwaysNode.__removeChild(value);},stop:function stop(){if(isDone){console.warn('Calling stop has no effect as the animation has already completed');return;}if(!isStarted){console.warn(\"Calling stop has no effect as the animation hasn't been started\");return;}wasStopped=true;(0,_evaluateOnce.evaluateOnce)((0,_base.set)(currentState.finished,1),currentState.finished);},__stopImmediately_testOnly:function __stopImmediately_testOnly(result){animation.stop();isDone=result;value.__detachAnimation(animation);}};return animation;}function backwardsCompatibleAnimWrapper(node,AnimationClass){return function(clock,state,config){if(config!==undefined){return node(clock,state,config);}return createOldAnimationObject(node,AnimationClass,clock,state);};}","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-reanimated/src/animations/backwardCompatibleAnimWrapper.js"],"names":["createOldAnimationObject","node","AnimationClass","value","config","newClock","Clock","currentState","getDefaultState","alwaysNode","isStarted","isDone","wasStopped","animationCallback","animation","start","currentAnimationCallback","finished","console","warn","isNativelyInitialized","position","__detachAnimation","__attachAnimation","__addChild","__detach","__removeChild","stop","__stopImmediately_testOnly","result","backwardsCompatibleAnimWrapper","clock","state","undefined"],"mappings":"2LAAA,6BAUA,4EACA,qDAEA,QAASA,CAAAA,wBAAT,CAAkCC,IAAlC,CAAwCC,cAAxC,CAAwDC,KAAxD,CAA+DC,MAA/D,CAAuE,CACrE,GAAMC,CAAAA,QAAQ,CAAG,GAAIC,uBAAJ,EAAjB,CACA,GAAMC,CAAAA,YAAY,CAAGL,cAAc,CAACM,eAAf,EAArB,CACA,GAAIC,CAAAA,UAAJ,CACA,GAAIC,CAAAA,SAAS,CAAG,KAAhB,CACA,GAAIC,CAAAA,MAAM,CAAG,KAAb,CACA,GAAIC,CAAAA,UAAU,CAAG,KAAjB,CACA,GAAIC,CAAAA,iBAAJ,CACA,GAAMC,CAAAA,SAAS,CAAG,CAChBC,KAAK,CAAE,eAAAC,wBAAwB,CAAI,CACjCH,iBAAiB,CAAGG,wBAApB,CACA,GAAIN,SAAJ,CAAe,CACbG,iBAAiB,EAAIA,iBAAiB,CAAC,CAAEI,QAAQ,CAAE,KAAZ,CAAD,CAAtC,CACA,OACD,CACD,GAAIN,MAAJ,CAAY,CACVO,OAAO,CAACC,IAAR,CAAa,oCAAb,EAEA,OACD,CAED,GAAI,CAAChB,KAAK,CAACiB,qBAAN,EAAL,CAAoC,CAClC,OACD,CAEDV,SAAS,CAAG,IAAZ,CACA,+BACE,cAAIH,YAAY,CAACc,QAAjB,CAA2BlB,KAA3B,CADF,CAEEI,YAAY,CAACc,QAFf,CAGE,UAAM,CACJZ,UAAU,CAAG,iB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,IAAV,GACAhB,MAAM,CAAGkB,MAAT,CACA1B,KAAK,CAACmB,iBAAN,CAAwBR,SAAxB,EACD,CA5Ee,CAAlB,CA8EA,MAAOA,CAAAA,SAAP,CACD,CAMc,QAASgB,CAAAA,8BAAT,CAAwC7B,IAAxC,CAA8CC,cAA9C,CAA8D,CAC3E,MAAO,UAAC6B,KAAD,CAAQC,KAAR,CAAe5B,MAAf,CAA0B,CAC/B,GAAIA,MAAM,GAAK6B,SAAf,CAA0B,CACxB,MAAOhC,CAAAA,IAAI,CAAC8B,KAAD,CAAQC,KAAR,CAAe5B,MAAf,CAAX,CACD,CACD,MAAOJ,CAAAA,wBAAwB,CAACC,IAAD,CAAOC,cAAP,CAAuB6B,KAAvB,CAA8BC,KAA9B,CAA/B,CACD,CALD,CAMD","sourcesContent":["import {\n  always,\n  block,\n  call,\n  clockRunning,\n  cond,\n  set,\n  startClock,\n  stopClock,\n} from '../base';\nimport { default as Clock } from '../core/AnimatedClock';\nimport { evaluateOnce } from '../derived/evaluateOnce';\n\nfunction createOldAnimationObject(node, AnimationClass, value, config) {\n  const newClock = new Clock();\n  const currentState = AnimationClass.getDefaultState();\n  let alwaysNode;\n  let isStarted = false;\n  let isDone = false;\n  let wasStopped = false;\n  let animationCallback;\n  const animation = {\n    start: currentAnimationCallback => {\n      animationCallback = currentAnimationCallback;\n      if (isStarted) {\n        animationCallback && animationCallback({ finished: false });\n        return;\n      }\n      if (isDone) {\n        console.warn('Animation has been finished before');\n        // inconsistent with React Native\n        return;\n      }\n\n      if (!value.isNativelyInitialized()) {\n        return;\n      }\n\n      isStarted = true;\n      evaluateOnce(\n        set(currentState.position, value),\n        currentState.position,\n        () => {\n          alwaysNode = always(\n            set(\n              value,\n              block([\n                cond(clockRunning(newClock), 0, startClock(newClock)),\n                node(newClock, currentState, config),\n                cond(currentState.finished, [\n                  call([], () => {\n                    isStarted = false;\n                    if (!wasStopped) {\n                      isDone = true;\n                    }\n                    value.__detachAnimation(animation);\n                    isDone = true;\n                    if (!wasStopped) {\n                      wasStopped = false;\n                    }\n                  }),\n                  stopClock(newClock),\n                ]),\n                currentState.position,\n              ])\n            )\n          );\n          value.__attachAnimation(animation);\n          alwaysNode.__addChild(value);\n        }\n      );\n    },\n    __detach: () => {\n      animationCallback && animationCallback({ finished: isDone });\n      animationCallback = null;\n      alwaysNode.__removeChild(value);\n    },\n    stop: () => {\n      if (isDone) {\n        console.warn(\n          'Calling stop has no effect as the animation has already completed'\n        );\n        return;\n      }\n      if (!isStarted) {\n        console.warn(\n          \"Calling stop has no effect as the animation hasn't been started\"\n        );\n        return;\n      }\n      wasStopped = true;\n      evaluateOnce(set(currentState.finished, 1), currentState.finished);\n    },\n    __stopImmediately_testOnly: result => {\n      animation.stop();\n      isDone = result;\n      value.__detachAnimation(animation);\n    },\n  };\n  return animation;\n}\n\n/**\n * Depending on the arguments list we either return animation node or return an\n * animation object that is compatible with the original Animated API\n */\nexport default function backwardsCompatibleAnimWrapper(node, AnimationClass) {\n  return (clock, state, config) => {\n    if (config !== undefined) {\n      return node(clock, state, config);\n    }\n    return createOldAnimationObject(node, AnimationClass, clock, state);\n  };\n}\n"]},"metadata":{},"sourceType":"script"}