{ "version": 3, "sources": [ "raf.ts" ], "names": [ "request", "cancel", "lastTime", "callback", "token", "init", "window", "requestAnimationFrame", "cancelAnimationFrame", "vendors", "vendor", "bind", "currTime", "Date", "now", "timeToCall", "Math", "max", "setTimeout", "clearTimeout" ], "mappings": "AAAA,IACIA,EACAC,EAFAC,EAAW,gBAqCA,CACbF,QAAUG,GAAmCH,EAAQG,GACrDF,OAASG,GAAkBH,EAAOG,GAClCC,KApCaC,GAIb,GAHAN,EAAUM,EAAOC,sBACjBN,EAASK,EAAOE,sBAEXR,EAAS,CACZ,MAAMS,EAAU,CAAC,KAAM,MAAO,SAAU,KAExC,IAAK,MAAMC,KAAUD,EACnBT,EAAUM,EAAUI,EAAF,yBAClBT,EAASK,EAAUI,EAAF,yBACfJ,EAAUI,EAAF,+BAIdV,EAAUA,GAAWA,EAAQW,KAAKL,GAClCL,EAASA,GAAUA,EAAOU,KAAKL,GAE1BN,IACHA,EAAUG,IACR,MAAMS,EAAWC,KAAKC,MAChBC,EAAaC,KAAKC,IAAI,EAAG,IAAML,EAAWV,IAE1CE,EAAQE,EAAOY,YAAW,KAAQf,EAASS,EAAWG,KAC1DA,GAGF,OADAb,EAAWU,EAAWG,EACfX,GAGTH,EAASG,GAASe,aAAaf", "sourcesContent": [ "let lastTime = 0\nlet request: typeof requestAnimationFrame\nlet cancel: typeof cancelAnimationFrame\n\nfunction init (window: Window) {\n request = window.requestAnimationFrame\n cancel = window.cancelAnimationFrame\n\n if (!request) {\n const vendors = ['ms', 'moz', 'webkit', 'o']\n\n for (const vendor of vendors) {\n request = window[`${vendor}RequestAnimationFrame` as 'requestAnimationFrame']\n cancel = window[`${vendor}CancelAnimationFrame` as 'cancelAnimationFrame'] ||\n window[`${vendor}CancelRequestAnimationFrame` as 'cancelAnimationFrame']\n }\n }\n\n request = request && request.bind(window)\n cancel = cancel && cancel.bind(window)\n\n if (!request) {\n request = callback => {\n const currTime = Date.now()\n const timeToCall = Math.max(0, 16 - (currTime - lastTime))\n // eslint-disable-next-line node/no-callback-literal\n const token = window.setTimeout(() => { callback(currTime + timeToCall) },\n timeToCall)\n\n lastTime = currTime + timeToCall\n return token\n }\n\n cancel = token => clearTimeout(token)\n }\n}\n\nexport default {\n request: (callback: FrameRequestCallback) => request(callback),\n cancel: (token: number) => cancel(token),\n init,\n}\n" ] }