Skip to content

Commit

Permalink
refactor(TypeScript): move AnimateManager to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
Coltin Kifer committed Sep 9, 2024
1 parent bc89a98 commit fb43c5e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/AnimateManager.js → src/AnimateManager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import setRafTimeout from './setRafTimeout';

type ReactSmoothStyleType = string | string[] | Record<string, unknown> | (() => 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;
}
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit fb43c5e

Please sign in to comment.