1 line
6.0 KiB
JSON
1 line
6.0 KiB
JSON
|
|
{"ast":null,"code":"import { invariant, warning } from 'motion-utils';\nimport { useContext } from 'react';\nimport { MotionContext } from '../context/MotionContext/index.mjs';\nimport { useMotionValue } from './use-motion-value.mjs';\nimport { useTransform } from './use-transform.mjs';\n\n// Keep things reasonable and avoid scale: Infinity. In practise we might need\n// to add another value, opacity, that could interpolate scaleX/Y [0,0.01] => [0,1]\n// to simply hide content at unreasonable scales.\nconst maxScale = 100000;\nconst invertScale = scale => scale > 0.001 ? 1 / scale : maxScale;\nlet hasWarned = false;\n/**\n * Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse\n * of their respective parent scales.\n *\n * This is useful for undoing the distortion of content when scaling a parent component.\n *\n * By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.\n * By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output\n * of those instead.\n *\n * ```jsx\n * const MyComponent = () => {\n * const { scaleX, scaleY } = useInvertedScale()\n * return <motion.div style={{ scaleX, scaleY }} />\n * }\n * ```\n *\n * @deprecated\n */\nfunction useInvertedScale(scale) {\n let parentScaleX = useMotionValue(1);\n let parentScaleY = useMotionValue(1);\n const {\n visualElement\n } = useContext(MotionContext);\n invariant(!!(scale || visualElement), \"If no scale values are provided, useInvertedScale must be used within a child of another motion component.\");\n warning(hasWarned, \"useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.\");\n hasWarned = true;\n if (scale) {\n parentScaleX = scale.scaleX || parentScaleX;\n parentScaleY = scale.scaleY || parentScaleY;\n } else if (visualElement) {\n parentScaleX = visualElement.getValue(\"scaleX\", 1);\n parentScaleY = visualElement.getValue(\"scaleY\", 1);\n }\n const scaleX = useTransform(parentScaleX, invertScale);\n const scaleY = useTransform(parentScaleY, invertScale);\n return {\n scaleX,\n scaleY\n };\n}\nexport { invertScale, useInvertedScale };","map":{"version":3,"names":["invariant","warning","useContext","MotionContext","useMotionValue","useTransform","maxScale","invertScale","scale","hasWarned","useInvertedScale","parentScaleX","parentScaleY","visualElement","scaleX","scaleY","getValue"],"sources":["/Users/apple/Documents/cursor/Web课件/AI课/education_web_多Agent协作系统/node_modules/framer-motion/dist/es/value/use-inverted-scale.mjs"],"sourcesContent":["import { invariant, warning } from 'motion-utils';\nimport { useContext } from 'react';\nimport { MotionContext } from '../context/MotionContext/index.mjs';\nimport { useMotionValue } from './use-motion-value.mjs';\nimport { useTransform } from './use-transform.mjs';\n\n// Keep things reasonable and avoid scale: Infinity. In practise we might need\n// to add another value, opacity, that could interpolate scaleX/Y [0,0.01] => [0,1]\n// to simply hide content at unreasonable scales.\nconst maxScale = 100000;\nconst invertScale = (scale) => scale > 0.001 ? 1 / scale : maxScale;\nlet hasWarned = false;\n/**\n * Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse\n * of their respective parent scales.\n *\n * This is useful for undoing the distortion of content when scaling a parent component.\n *\n * By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.\n * By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output\n * of those instead.\n *\n * ```jsx\n * const MyComponent = () => {\n * const { scaleX, scaleY } = useInvertedScale()\n * return <motion.div style={{ scaleX, scaleY }} />\n * }\n * ```\n *\n * @deprecated\n */\nfunction useInvertedScale(scale) {\n let parentScaleX = useMotionValue(1);\n let parentScaleY = useMotionValue(1);\n const { visualElement } = useContext(M
|