animation.mjs.map 4.3 KB

1
  1. {"version":3,"file":"animation.mjs","names":["Box","nullifyTransforms","el","rect","getBoundingClientRect","style","getComputedStyle","tx","transform","ta","sx","sy","dx","dy","startsWith","slice","split","to","transformOrigin","x","parseFloat","y","indexOf","w","width","offsetWidth","h","height","offsetHeight","animate","keyframes","options","finished","Promise","resolve","animation","err","onfinish"],"sources":["../../src/util/animation.ts"],"sourcesContent":["// Utilities\nimport { Box } from '@/util/box'\n\n/** @see https://stackoverflow.com/a/57876601/2074736 */\nexport function nullifyTransforms (el: HTMLElement): Box {\n const rect = el.getBoundingClientRect()\n const style = getComputedStyle(el)\n const tx = style.transform\n\n if (tx) {\n let ta, sx, sy, dx, dy\n if (tx.startsWith('matrix3d(')) {\n ta = tx.slice(9, -1).split(/, /)\n sx = +ta[0]\n sy = +ta[5]\n dx = +ta[12]\n dy = +ta[13]\n } else if (tx.startsWith('matrix(')) {\n ta = tx.slice(7, -1).split(/, /)\n sx = +ta[0]\n sy = +ta[3]\n dx = +ta[4]\n dy = +ta[5]\n } else {\n return new Box(rect)\n }\n\n const to = style.transformOrigin\n const x = rect.x - dx - (1 - sx) * parseFloat(to)\n const y = rect.y - dy - (1 - sy) * parseFloat(to.slice(to.indexOf(' ') + 1))\n const w = sx ? rect.width / sx : el.offsetWidth + 1\n const h = sy ? rect.height / sy : el.offsetHeight + 1\n\n return new Box({ x, y, width: w, height: h })\n } else {\n return new Box(rect)\n }\n}\n\nexport function animate (\n el: Element,\n keyframes: Keyframe[] | PropertyIndexedKeyframes | null,\n options?: number | KeyframeAnimationOptions\n) {\n if (typeof el.animate === 'undefined') return { finished: Promise.resolve() }\n\n let animation: Animation\n try {\n animation = el.animate(keyframes, options)\n } catch (err) {\n return { finished: Promise.resolve() }\n }\n\n if (typeof animation.finished === 'undefined') {\n (animation as any).finished = new Promise(resolve => {\n animation.onfinish = () => {\n resolve(animation)\n }\n })\n }\n\n return animation\n}\n"],"mappings":"AAAA;AAAA,SACSA,GAAG;AAEZ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