use-spring-transition
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -11,3 +11,3 @@ "use strict"; | ||
const useSpringTransitions = (value, options = {}, values = { from: 0, to: 1 }) => { | ||
const transitionIdRef = (0, react_1.useRef)(null); | ||
const transitionIdRef = (0, react_1.useRef)(-1); | ||
const [inst, setState] = (0, react_1.useState)({ | ||
@@ -63,5 +63,2 @@ transitions: [ | ||
const transitionId = transitionIdRef.current; | ||
if (!transitionId) { | ||
return; | ||
} | ||
const isOpenClosePending = !timeoutMapRef.current[transitionId] && | ||
@@ -98,7 +95,7 @@ transitions.some((transition) => ['open', 'close'].includes(transition.stage) && transition._transitionId === transitionId); | ||
} | ||
const springValuesByValueMap = transitions.reduce((res, transition) => { | ||
res.set(transition.value, transition.springValue); | ||
return res; | ||
}, new Map()); | ||
const openClose = ({ open, close }, openCloseOptions) => { | ||
const springValuesByValueMap = transitions.reduce((res, transition) => { | ||
res.set(transition.value, transition.springValue); | ||
return res; | ||
}, new Map()); | ||
const cleanup = (0, spring_1.spring)({ | ||
@@ -194,3 +191,3 @@ options: openCloseOptions, | ||
(0, react_1.useEffect)(() => () => { | ||
transitionIdRef.current = null; | ||
transitionIdRef.current = -1; | ||
Object.keys(timeoutMapRef.current).forEach((key) => { | ||
@@ -197,0 +194,0 @@ clearTimeout(timeoutMapRef.current[key]); |
{ | ||
"name": "use-spring-transition", | ||
"sideEffects": false, | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Hooks for spring transition", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
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
32705
451