Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function useParallax(positiveOffset: MotionValue, ...rangeFunPairs) {
const processedRangeFunPairs = preprocessRangeFun(rangeFunPairs)
const getRange = index =>
processedRangeFunPairs[index] && processedRangeFunPairs[index][0]
const getFun = index =>
processedRangeFunPairs[index] && processedRangeFunPairs[index][1]
return useTransform(positiveOffset, v => {
let lastV = 0
for (let i = 0; i < processedRangeFunPairs.length; i++) {
const range = getRange(i)
const fun = getFun(i)
if (v < range[0]) {
const prevFun = getFun(i - 1)
const prevRange = getRange(i - 1)
prevFun && (lastV = prevFun(prevRange[1]))
} else if (v <= range[1]) {
const nv = fun(v - range[0]) + lastV
return nv
} else {
/* v > range[1] */
lastV = fun(range[1] - range[0]) + lastV
}
}
const MobileModal = ({ tickets, open, setOpen }) => {
const [size, setSize] = useState("100%")
const pathPos = useSpring(0, { springConfig })
const path = useTransform(pathPos, value =>
interpolator(transform(value, [0, 1], [0, 1]))
)
useEffect(() => {
const timer = setTimeout(
() => {
pathPos.set(open ? 1 : 0)
},
open ? 400 : 500
)
return () => clearTimeout(timer)
}, [open, pathPos])
useEffect(() => {
const getSize = debounce(() => {
setSize(window.innerHeight)
export const RegularFrame: Override = () => {
return { height: useTransform(controller.progress.y, v => v * 100) }
}
export function usePositiveOffset(
offset: MotionValue
): MotionValue {
return useTransform(offset, v => -v)
}