@react-spring/core
Advanced tools
Comparing version 9.4.0-beta.4 to 9.4.0-beta.6
import { Valid } from '../types/common'; | ||
import { PickAnimated, SpringValues } from '../types'; | ||
import { UseSpringProps } from './useSpring'; | ||
import { SpringRef } from '../SpringRef'; | ||
import { Controller } from '../Controller'; | ||
import { UseSpringProps } from './useSpring'; | ||
export declare type UseTrailProps<Props extends object = any> = UseSpringProps<Props>; | ||
@@ -7,0 +7,0 @@ export declare function useTrail<Props extends object>(length: number, props: (i: number, ctrl: Controller) => UseTrailProps | (Props & Valid<Props, UseTrailProps<Props>>), deps?: readonly any[]): PickAnimated<Props> extends infer State ? [SpringValues<State>[], SpringRef<State>] : never; |
import { Lookup, Falsy, OneOrMore } from '@react-spring/types'; | ||
import { AsyncResult, ControllerUpdate } from './types'; | ||
import { Controller } from './Controller'; | ||
interface ControllerUpdateFn<State extends Lookup = Lookup> { | ||
export interface ControllerUpdateFn<State extends Lookup = Lookup> { | ||
(i: number, ctrl: Controller<State>): ControllerUpdate<State> | Falsy; | ||
@@ -57,2 +57,1 @@ } | ||
export declare const SpringRef: <State extends Lookup<any> = Lookup<any>>() => SpringRef<State>; | ||
export {}; |
@@ -167,4 +167,4 @@ import { eachProp, is, toArray, isAnimatedString, Globals, getFluidValue, useLayoutEffect, each, raf, flush, FluidValue, deprecateInterpolate, callFluidObservers, frameLoop, hasFluidValue, flushCalls, isEqual, getFluidObservers, addFluidObserver, removeFluidObserver, noop, useMemoOne, deprecateDirectCall, useForceUpdate, usePrev, useOnce, createInterpolator, createStringInterpolator } from '@react-spring/shared'; | ||
}); | ||
ctrl.start(); | ||
}); | ||
ref.start(); | ||
} | ||
@@ -412,3 +412,3 @@ }); | ||
function onResume() { | ||
if (delay > 0) { | ||
if (delay > 0 && !Globals.skipAnimation) { | ||
state.delayed = true; | ||
@@ -2052,20 +2052,46 @@ timeout = raf.setTimeout(onStart, delay); | ||
function useTrail(length, propsArg, deps) { | ||
var _passedRef; | ||
const propsFn = is.fun(propsArg) && propsArg; | ||
if (propsFn && !deps) deps = []; | ||
let reverse = true; | ||
let passedRef = undefined; | ||
const result = useSprings(length, (i, ctrl) => { | ||
const props = propsFn ? propsFn(i, ctrl) : propsArg; | ||
passedRef = props.ref; | ||
reverse = reverse && props.reverse; | ||
return props; | ||
}, deps || [{}]); | ||
const ref = result[1]; | ||
const ref = (_passedRef = passedRef) != null ? _passedRef : result[1]; | ||
useLayoutEffect(() => { | ||
each(ref.current, (ctrl, i) => { | ||
const parent = ref.current[i + (reverse ? 1 : -1)]; | ||
if (parent) ctrl.start({ | ||
to: parent.springs | ||
}); | ||
if (parent) { | ||
ctrl.start({ | ||
to: parent.springs | ||
}); | ||
} else { | ||
ctrl.start(); | ||
} | ||
}); | ||
}, deps); | ||
ref['start'] = propsArg => { | ||
const results = []; | ||
each(ref.current, (ctrl, i) => { | ||
const props = is.fun(propsArg) ? propsArg(i, ctrl) : propsArg; | ||
const parent = ref.current[i + (reverse ? 1 : -1)]; | ||
if (parent) { | ||
results.push(ctrl.start(_extends({}, props, { | ||
to: parent.springs | ||
}))); | ||
} else { | ||
results.push(ctrl.start(_extends({}, props))); | ||
} | ||
}); | ||
return results; | ||
}; | ||
if (propsFn || arguments.length == 3) { | ||
@@ -2072,0 +2098,0 @@ ref['_getProps'] = (propsArg, ctrl, i) => { |
{ | ||
"name": "@react-spring/core", | ||
"version": "9.4.0-beta.4", | ||
"version": "9.4.0-beta.6", | ||
"main": "dist/react-spring-core.cjs.js", | ||
@@ -34,6 +34,6 @@ "module": "dist/react-spring-core.esm.js", | ||
"dependencies": { | ||
"@react-spring/animated": "~9.4.0-beta.2", | ||
"@react-spring/rafz": "~9.4.0-beta.2", | ||
"@react-spring/shared": "~9.4.0-beta.2", | ||
"@react-spring/types": "~9.4.0-beta.2" | ||
"@react-spring/animated": "~9.4.0-beta.6", | ||
"@react-spring/rafz": "~9.4.0-beta.6", | ||
"@react-spring/shared": "~9.4.0-beta.6", | ||
"@react-spring/types": "~9.4.0-beta.6" | ||
}, | ||
@@ -40,0 +40,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
261835
8075