1 line
5.9 KiB
JSON
1 line
5.9 KiB
JSON
{"ast":null,"code":"import { MotionValue } from '../../value/index.mjs';\nimport { px } from '../../value/types/numbers/units.mjs';\nimport { addAttrValue } from '../attr/index.mjs';\nimport { addStyleValue } from '../style/index.mjs';\nimport { createSelectorEffect } from '../utils/create-dom-effect.mjs';\nimport { createEffect } from '../utils/create-effect.mjs';\nimport { frame } from '../../frameloop/frame.mjs';\nconst toPx = px.transform;\nfunction addSVGPathValue(element, state, key, value) {\n frame.render(() => element.setAttribute(\"pathLength\", \"1\"));\n if (key === \"pathOffset\") {\n return state.set(key, value, () => element.setAttribute(\"stroke-dashoffset\", toPx(-state.latest[key])));\n } else {\n if (!state.get(\"stroke-dasharray\")) {\n state.set(\"stroke-dasharray\", new MotionValue(\"1 1\"), () => {\n const {\n pathLength = 1,\n pathSpacing\n } = state.latest;\n element.setAttribute(\"stroke-dasharray\", `${toPx(pathLength)} ${toPx(pathSpacing ?? 1 - Number(pathLength))}`);\n });\n }\n return state.set(key, value, undefined, state.get(\"stroke-dasharray\"));\n }\n}\nconst addSVGValue = (element, state, key, value) => {\n if (key.startsWith(\"path\")) {\n return addSVGPathValue(element, state, key, value);\n } else if (key.startsWith(\"attr\")) {\n return addAttrValue(element, state, convertAttrKey(key), value);\n }\n const handler = key in element.style ? addStyleValue : addAttrValue;\n return handler(element, state, key, value);\n};\nconst svgEffect = /*@__PURE__*/createSelectorEffect(/*@__PURE__*/createEffect(addSVGValue));\nfunction convertAttrKey(key) {\n return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());\n}\nexport { svgEffect };","map":{"version":3,"names":["MotionValue","px","addAttrValue","addStyleValue","createSelectorEffect","createEffect","frame","toPx","transform","addSVGPathValue","element","state","key","value","render","setAttribute","set","latest","get","pathLength","pathSpacing","Number","undefined","addSVGValue","startsWith","convertAttrKey","handler","style","svgEffect","replace","_","firstChar","toLowerCase"],"sources":["/home/gnx/Desktop/ETB/ETB-FrontEnd/node_modules/motion-dom/dist/es/effects/svg/index.mjs"],"sourcesContent":["import { MotionValue } from '../../value/index.mjs';\nimport { px } from '../../value/types/numbers/units.mjs';\nimport { addAttrValue } from '../attr/index.mjs';\nimport { addStyleValue } from '../style/index.mjs';\nimport { createSelectorEffect } from '../utils/create-dom-effect.mjs';\nimport { createEffect } from '../utils/create-effect.mjs';\nimport { frame } from '../../frameloop/frame.mjs';\n\nconst toPx = px.transform;\nfunction addSVGPathValue(element, state, key, value) {\n frame.render(() => element.setAttribute(\"pathLength\", \"1\"));\n if (key === \"pathOffset\") {\n return state.set(key, value, () => element.setAttribute(\"stroke-dashoffset\", toPx(-state.latest[key])));\n }\n else {\n if (!state.get(\"stroke-dasharray\")) {\n state.set(\"stroke-dasharray\", new MotionValue(\"1 1\"), () => {\n const { pathLength = 1, pathSpacing } = state.latest;\n element.setAttribute(\"stroke-dasharray\", `${toPx(pathLength)} ${toPx(pathSpacing ?? 1 - Number(pathLength))}`);\n });\n }\n return state.set(key, value, undefined, state.get(\"stroke-dasharray\"));\n }\n}\nconst addSVGValue = (element, state, key, value) => {\n if (key.startsWith(\"path\")) {\n return addSVGPathValue(element, state, key, value);\n }\n else if (key.startsWith(\"attr\")) {\n return addAttrValue(element, state, convertAttrKey(key), value);\n }\n const handler = key in element.style ? addStyleValue : addAttrValue;\n return handler(element, state, key, value);\n};\nconst svgEffect = /*@__PURE__*/ createSelectorEffect(\n/*@__PURE__*/ createEffect(addSVGValue));\nfunction convertAttrKey(key) {\n return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());\n}\n\nexport { svgEffect };\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,uBAAuB;AACnD,SAASC,EAAE,QAAQ,qCAAqC;AACxD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,oBAAoB,QAAQ,gCAAgC;AACrE,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,KAAK,QAAQ,2BAA2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