@react-spring/core
Advanced tools
Comparing version 9.0.0-canary.809.3.a66b280 to 9.0.0-canary.809.4.a637589
import { RefObject, ReactNode } from 'react'; | ||
import { Constrain, ObjectFromUnion, FluidValue, ObjectType, OneOrMore, Animatable, Merge, EasingFunction, UnknownPartial, UnknownProps as UnknownProps$1, FluidProps, Remap, Indexable as Indexable$1, Any as Any$1, Falsy as Falsy$1 } from '@react-spring/shared'; | ||
export { Globals, createInterpolator, isFluidValue, makeFluidValue } from '@react-spring/shared'; | ||
export { Animatable, Globals, createInterpolator, isFluidValue, makeFluidValue } from '@react-spring/shared'; | ||
import { AnimationValue, OnChange, AnimatedValue, Into } from '@react-spring/animated'; | ||
@@ -702,3 +702,3 @@ export { AnimationValue, Into, isAnimationValue } from '@react-spring/animated'; | ||
declare type Key = string | number; | ||
declare type ItemKeys<T> = Key | ReadonlyArray<Key> | ((item: T) => Key) | null; | ||
declare type ItemKeys<T = any> = OneOrMore<Key> | ((item: T) => Key) | null; | ||
declare type UseTransitionProps<Item = any> = Merge<AnimationProps & AnimationEvents, { | ||
@@ -705,0 +705,0 @@ /** |
59
index.js
@@ -703,3 +703,3 @@ import { useIsomorphicLayoutEffect, each, is, toArray, isFluidValue, needsInterpolation, isEqual, usePrev, useOnce, useForceUpdate, Globals } from '@react-spring/shared'; | ||
let started = parent || (changed || reset) && !isEqual(value, to); | ||
let started = !!parent || (changed || reset) && !isEqual(value, to); | ||
/** The initial velocity before this `animate` call. */ | ||
@@ -737,12 +737,5 @@ | ||
started = !isEqual(config.velocity, lastVelocity); | ||
} | ||
/** | ||
* The final value of the animation. | ||
* | ||
* The `FrameLoop` decides our goal value when a `parent` exists. | ||
*/ | ||
} // Reset our internal `Animated` node if starting. | ||
let goal = parent ? null : computeGoal(to); // Reset our internal `Animated` node if starting. | ||
let node = this.node; | ||
@@ -759,4 +752,8 @@ let nodeType; | ||
nodeType = node.constructor; | ||
} | ||
} // The final value of our animation, excluding the "to" value. | ||
// The "FrameLoop" decides our goal value when "parent" exists. | ||
let goal = parent ? null : computeGoal(to); | ||
if (nodeType == AnimatedString) { | ||
@@ -1363,5 +1360,12 @@ from = 0; | ||
const LEAVE = 3; | ||
function getKeys(items, _ref) { | ||
let key = _ref.key, | ||
_ref$keys = _ref.keys, | ||
keys = _ref$keys === void 0 ? key : _ref$keys; | ||
return is.und(keys) ? items : is.fun(keys) ? items.map(keys) : toArray(keys); | ||
} | ||
function useTransition(data, props, deps) { | ||
const key = props.key, | ||
ref = props.ref, | ||
const ref = props.ref, | ||
reset = props.reset, | ||
@@ -1372,9 +1376,4 @@ sort = props.sort, | ||
_props$expires = props.expires, | ||
expires = _props$expires === void 0 ? Infinity : _props$expires; | ||
expires = _props$expires === void 0 ? Infinity : _props$expires; // Every item has its own transition. | ||
if ('keys' in props) { | ||
console.warn('Unknown prop "keys" was passed to useTransition. Did you mean "key"?'); | ||
} // Every item has its own transition. | ||
const items = toArray(data); | ||
@@ -1386,3 +1385,3 @@ const transitions = []; // Keys help with reusing transitions between renders. | ||
const keys = is.und(key) ? items : is.fun(key) ? items.map(key) : toArray(key); // The "onRest" callbacks need a ref to the latest transitions. | ||
const keys = getKeys(items, props); // The "onRest" callbacks need a ref to the latest transitions. | ||
@@ -1558,5 +1557,5 @@ const usedTransitions = useRef(null); | ||
useIsomorphicLayoutEffect(() => { | ||
each(changes, (_ref, t) => { | ||
let phase = _ref.phase, | ||
payload = _ref.payload; | ||
each(changes, (_ref2, t) => { | ||
let phase = _ref2.phase, | ||
payload = _ref2.payload; | ||
t.phase = phase; | ||
@@ -1785,11 +1784,4 @@ if (payload) t.ctrl.update(payload); | ||
const canFinish = !payload || payload[i].done; | ||
const config = anim.config; // Loose springs never move. | ||
const canFinish = !payload || payload[i].done; // Jump to end value for immediate animations. | ||
if (config.tension == 0) { | ||
node.done = true; | ||
return; | ||
} // Jump to end value for immediate animations. | ||
if (anim.immediate) { | ||
@@ -1805,2 +1797,9 @@ node.done = canFinish; | ||
const config = anim.config; // Loose springs never move. | ||
if (config.tension == 0) { | ||
node.done = true; | ||
return; | ||
} | ||
const elapsed = node.elapsedTime += dt; | ||
@@ -1807,0 +1806,0 @@ const from = anim.fromValues[i]; |
{ | ||
"name": "@react-spring/core", | ||
"version": "9.0.0-canary.809.3.a66b280", | ||
"version": "9.0.0-canary.809.4.a637589", | ||
"description": "Cross-platform animation engine for React", | ||
@@ -34,4 +34,4 @@ "keywords": [ | ||
"@babel/runtime": "^7.3.1", | ||
"@react-spring/animated": "9.0.0-canary.809.3.a66b280", | ||
"@react-spring/shared": "9.0.0-canary.809.3.a66b280", | ||
"@react-spring/animated": "9.0.0-canary.809.4.a637589", | ||
"@react-spring/shared": "9.0.0-canary.809.4.a637589", | ||
"use-memo-one": "^1.1.0" | ||
@@ -38,0 +38,0 @@ }, |
@@ -204,10 +204,2 @@ import { FrameRequestCallback } from '@react-spring/shared/types' | ||
const { config } = anim | ||
// Loose springs never move. | ||
if (config.tension == 0) { | ||
node.done = true | ||
return | ||
} | ||
// Jump to end value for immediate animations. | ||
@@ -222,2 +214,10 @@ if (anim.immediate) { | ||
const { config } = anim | ||
// Loose springs never move. | ||
if (config.tension == 0) { | ||
node.done = true | ||
return | ||
} | ||
const elapsed = (node.elapsedTime += dt) | ||
@@ -224,0 +224,0 @@ const from = anim.fromValues[i] |
@@ -38,5 +38,10 @@ export * from './useChain' | ||
export { isAnimationValue, AnimationValue } from '@react-spring/animated' | ||
export { createInterpolator, isFluidValue, makeFluidValue } from '@react-spring/shared' | ||
export { | ||
Animatable, | ||
createInterpolator, | ||
isFluidValue, | ||
makeFluidValue, | ||
} from '@react-spring/shared' | ||
export * from '@react-spring/shared/types/animated' | ||
export * from '@react-spring/shared/types/interpolation' |
@@ -40,3 +40,3 @@ import { | ||
import { callProp, DEFAULT_PROPS, matchProp } from './helpers' | ||
import { config } from './constants' | ||
import { config as configs } from './constants' | ||
@@ -75,3 +75,3 @@ /** Default props for a `SpringValue` object */ | ||
const BASE_CONFIG: SpringConfig = { | ||
...config.default, | ||
...configs.default, | ||
mass: 1, | ||
@@ -434,3 +434,3 @@ velocity: 0, | ||
/** When true, this spring must be in the frameloop. */ | ||
let started = parent || ((changed || reset) && !isEqual(value, to)) | ||
let started = !!parent || ((changed || reset) && !isEqual(value, to)) | ||
@@ -474,9 +474,2 @@ /** The initial velocity before this `animate` call. */ | ||
/** | ||
* The final value of the animation. | ||
* | ||
* The `FrameLoop` decides our goal value when a `parent` exists. | ||
*/ | ||
let goal: any = parent ? null : computeGoal(to) | ||
// Reset our internal `Animated` node if starting. | ||
@@ -496,2 +489,6 @@ let node = this.node! | ||
// The final value of our animation, excluding the "to" value. | ||
// The "FrameLoop" decides our goal value when "parent" exists. | ||
let goal: any = parent ? null : computeGoal(to) | ||
if (nodeType == AnimatedString) { | ||
@@ -498,0 +495,0 @@ from = 0 as any |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
331378
7058
+ Added@react-spring/animated@9.0.0-canary.809.4.a637589(transitive)
+ Added@react-spring/shared@9.0.0-canary.809.4.a637589(transitive)
- Removed@react-spring/animated@9.0.0-canary.809.3.a66b280(transitive)
- Removed@react-spring/shared@9.0.0-canary.809.3.a66b280(transitive)