All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.animations.animate.js.map Maven / Gradle / Ivy

{"version":3,"file":"animate.js","sourceRoot":"","sources":["../../src/animations/animate.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,qBAAqB,CAAC;AASjD,MAAM,OAAO,GAAG,CAAC,OAAuB,EAAE,EAAE;IAC3C,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,cAAsB,CAAC;IAC3B,IAAI,IAAgB,CAAC;IACrB,IAAI,gBAA6C,CAAC;IAElD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,gBAAgB,GAAG,SAAS,CAAC,EAAE;YAC9B,KAAK,GAAG,KAAK,IAAI,SAAS,CAAC;YAE3B,MAAM,WAAW,GAAG,SAAS,GAAG,KAAK,CAAC;YACtC,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC;YAEjD,IAAI,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACpC,MAAM,cAAc,GAAG,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,oCAAoC;gBAC7F,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBAChC,IAAI,CAAC,OAAO,EAAE;oBACb,cAAc,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;iBACzD;aACD;iBAAM;gBACN,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACnB,OAAO,EAAE,CAAC;aACV;QACF,CAAC,CAAC;QAEF,IAAI,GAAG,GAAG,EAAE;YACX,OAAO,GAAG,IAAI,CAAC;YACf,oBAAoB,CAAC,cAAc,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC;IACH,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAa,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAEpC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE;QACzC,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,EAAE;YAC9C,OAAO,CAAC,WAAW,EAAE,CAAC;SACtB;QAED,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QAExC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACN,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;QACtB,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI;KAChB,CAAC;AACH,CAAC,CAAC;AACF,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,eAAe,OAAO,CAAC","sourcesContent":["import AnimationQueue from \"./AnimationQueue.js\";\n\ntype AnimateOptions = {\n\tbeforeStart?: () => void,\n\tduration: number,\n\telement: HTMLElement,\n\tadvance: (p: number) => void,\n};\n\nconst animate = (options: AnimateOptions) => {\n\tlet start: number | null = null;\n\tlet stopped = false;\n\tlet animationFrame: number;\n\tlet stop: () => void;\n\tlet advanceAnimation: (timestamp: number) => void;\n\n\tconst promise = new Promise((resolve, reject) => {\n\t\tadvanceAnimation = timestamp => {\n\t\t\tstart = start || timestamp;\n\n\t\t\tconst timeElapsed = timestamp - start;\n\t\t\tconst remaining = options.duration - timeElapsed;\n\n\t\t\tif (timeElapsed <= options.duration) {\n\t\t\t\tconst currentAdvance = 1 - remaining / options.duration; // easing formula (currently linear)\n\t\t\t\toptions.advance(currentAdvance);\n\t\t\t\tif (!stopped) {\n\t\t\t\t\tanimationFrame = requestAnimationFrame(advanceAnimation);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toptions.advance(1);\n\t\t\t\tresolve();\n\t\t\t}\n\t\t};\n\n\t\tstop = () => {\n\t\t\tstopped = true;\n\t\t\tcancelAnimationFrame(animationFrame);\n\t\t\treject(new Error(\"animation stopped\"));\n\t\t};\n\t}).catch((reason: Error) => reason);\n\n\tAnimationQueue.push(options.element, () => {\n\t\tif (typeof options.beforeStart === \"function\") {\n\t\t\toptions.beforeStart();\n\t\t}\n\n\t\trequestAnimationFrame(advanceAnimation);\n\n\t\treturn new Promise(resolve => {\n\t\t\tpromise.then(() => resolve());\n\t\t});\n\t});\n\n\treturn {\n\t\tpromise: () => promise,\n\t\tstop: () => stop,\n\t};\n};\nconst duration = 400;\n\nexport { duration };\nexport type { AnimateOptions };\nexport default animate;\n"]}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy