From fb43c5e8023d7d7241339ba0beaca1d00eaf5cf3 Mon Sep 17 00:00:00 2001 From: Coltin Kifer Date: Mon, 9 Sep 2024 16:49:42 +0000 Subject: [PATCH] refactor(TypeScript): move AnimateManager to TS --- src/{AnimateManager.js => AnimateManager.ts} | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) rename src/{AnimateManager.js => AnimateManager.ts} (70%) diff --git a/src/AnimateManager.js b/src/AnimateManager.ts similarity index 70% rename from src/AnimateManager.js rename to src/AnimateManager.ts index 5b6243b..d0e8432 100644 --- a/src/AnimateManager.js +++ b/src/AnimateManager.ts @@ -1,11 +1,15 @@ import setRafTimeout from './setRafTimeout'; +type ReactSmoothStyleType = string | string[] | Record | (() => void); + +type HandleChangeFn = (currentStyle?: ReactSmoothStyleType) => null | void; + export default function createAnimateManager() { let currStyle = {}; - let handleChange = () => null; + let handleChange: (currentStyle?: ReactSmoothStyleType) => null | void = () => null; let shouldStop = false; - const setStyle = _style => { + const setStyle = (_style: ReactSmoothStyleType) => { if (shouldStop) { return; } @@ -43,11 +47,11 @@ export default function createAnimateManager() { stop: () => { shouldStop = true; }, - start: style => { + start: (style: ReactSmoothStyleType) => { shouldStop = false; setStyle(style); }, - subscribe: _handleChange => { + subscribe: (_handleChange: HandleChangeFn) => { handleChange = _handleChange; return () => {