1 line
3.2 KiB
JSON
1 line
3.2 KiB
JSON
{"ast":null,"code":"import { useCallback } from 'react';\nimport { isRefObject } from '../../utils/is-ref-object.mjs';\n\n/**\n * Creates a ref function that, when called, hydrates the provided\n * external ref and VisualElement.\n */\nfunction useMotionRef(visualState, visualElement, externalRef) {\n return useCallback(instance => {\n if (instance) {\n visualState.onMount && visualState.onMount(instance);\n }\n if (visualElement) {\n if (instance) {\n visualElement.mount(instance);\n } else {\n visualElement.unmount();\n }\n }\n if (externalRef) {\n if (typeof externalRef === \"function\") {\n externalRef(instance);\n } else if (isRefObject(externalRef)) {\n externalRef.current = instance;\n }\n }\n },\n /**\n * Only pass a new ref callback to React if we've received a visual element\n * factory. Otherwise we'll be mounting/remounting every time externalRef\n * or other dependencies change.\n */\n [visualElement]);\n}\nexport { useMotionRef };","map":{"version":3,"names":["useCallback","isRefObject","useMotionRef","visualState","visualElement","externalRef","instance","onMount","mount","unmount","current"],"sources":["/home/gnx/Desktop/ETB/ETB-FrontEnd/node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.mjs"],"sourcesContent":["import { useCallback } from 'react';\nimport { isRefObject } from '../../utils/is-ref-object.mjs';\n\n/**\n * Creates a ref function that, when called, hydrates the provided\n * external ref and VisualElement.\n */\nfunction useMotionRef(visualState, visualElement, externalRef) {\n return useCallback((instance) => {\n if (instance) {\n visualState.onMount && visualState.onMount(instance);\n }\n if (visualElement) {\n if (instance) {\n visualElement.mount(instance);\n }\n else {\n visualElement.unmount();\n }\n }\n if (externalRef) {\n if (typeof externalRef === \"function\") {\n externalRef(instance);\n }\n else if (isRefObject(externalRef)) {\n externalRef.current = instance;\n }\n }\n }, \n /**\n * Only pass a new ref callback to React if we've received a visual element\n * factory. Otherwise we'll be mounting/remounting every time externalRef\n * or other dependencies change.\n */\n [visualElement]);\n}\n\nexport { useMotionRef };\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,OAAO;AACnC,SAASC,WAAW,QAAQ,+BAA+B;;AAE3D;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAACC,WAAW,EAAEC,aAAa,EAAEC,WAAW,EAAE;EAC3D,OAAOL,WAAW,CAAEM,QAAQ,IAAK;IAC7B,IAAIA,QAAQ,EAAE;MACVH,WAAW,CAACI,OAAO,IAAIJ,WAAW,CAACI,OAAO,CAACD,QAAQ,CAAC;IACxD;IACA,IAAIF,aAAa,EAAE;MACf,IAAIE,QAAQ,EAAE;QACVF,aAAa,CAACI,KAAK,CAACF,QAAQ,CAAC;MACjC,CAAC,MACI;QACDF,aAAa,CAACK,OAAO,CAAC,CAAC;MAC3B;IACJ;IACA,IAAIJ,WAAW,EAAE;MACb,IAAI,OAAOA,WAAW,KAAK,UAAU,EAAE;QACnCA,WAAW,CAACC,QAAQ,CAAC;MACzB,CAAC,MACI,IAAIL,WAAW,CAACI,WAAW,CAAC,EAAE;QAC/BA,WAAW,CAACK,OAAO,GAAGJ,QAAQ;MAClC;IACJ;EACJ,CAAC;EACD;AACJ;AACA;AACA;AACA;EACI,CAACF,aAAa,CAAC,CAAC;AACpB;AAEA,SAASF,YAAY","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]} |