main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
"use client";
import { attachSpring, isMotionValue } from 'motion-dom';
import { useContext, useInsertionEffect } from 'react';
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
import { useMotionValue } from './use-motion-value.mjs';
import { useTransform } from './use-transform.mjs';
function useSpring(source, options = {}) {
const { isStatic } = useContext(MotionConfigContext);
const getFromSource = () => (isMotionValue(source) ? source.get() : source);
// isStatic will never change, allowing early hooks return
if (isStatic) {
return useTransform(getFromSource);
}
const value = useMotionValue(getFromSource());
useInsertionEffect(() => {
return attachSpring(value, source, options);
}, [value, JSON.stringify(options)]);
return value;
}
export { useSpring };