framer-motion
Version:
A simple and powerful JavaScript animation library
1 lines • 1.46 kB
Source Map (JSON)
{"version":3,"file":"detect-axis.mjs","sources":["../../../../../src/components/Reorder/utils/detect-axis.ts"],"sourcesContent":["import { Axis, Box } from \"motion-utils\"\nimport { ReorderAxis } from \"../types\"\n\nconst isSeparated = (a: Axis, b: Axis) => a.max <= b.min || b.max <= a.min\n\nexport function detectAxis(layouts: Box[]): ReorderAxis {\n let x = false\n let y = false\n\n for (let i = 0; i < layouts.length; i++) {\n for (let j = i + 1; j < layouts.length; j++) {\n x ||= isSeparated(layouts[i].x, layouts[j].x)\n y ||= isSeparated(layouts[i].y, layouts[j].y)\n\n if (x && y) return \"xy\"\n }\n }\n\n return x ? \"x\" : \"y\"\n}\n"],"names":[],"mappings":"AAGA,MAAM,WAAW,GAAG,CAAC,CAAO,EAAE,CAAO,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG;AAEpE,SAAU,UAAU,CAAC,OAAc,EAAA;IACrC,IAAI,CAAC,GAAG,KAAK;IACb,IAAI,CAAC,GAAG,KAAK;AAEb,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACrC,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACzC,YAAA,CAAC,KAAD,CAAC,GAAK,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC7C,YAAA,CAAC,KAAD,CAAC,GAAK,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAE7C,IAAI,CAAC,IAAI,CAAC;AAAE,gBAAA,OAAO,IAAI;QAC3B;IACJ;IAEA,OAAO,CAAC,GAAG,GAAG,GAAG,GAAG;AACxB;;;;"}