Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Simplify useStyleTransition animate function

+4 -5
+4 -5
src/useStyleTransition.ts
··· 107 107 return promise; 108 108 }; 109 109 110 + export type Animate = (options: TransitionOptions) => Promise<void> | void; 111 + 110 112 export function useStyleTransition<T extends HTMLElement>( 111 113 ref: Ref<T>, 112 114 options?: TransitionOptions 113 - ): [boolean, (options: TransitionOptions) => Promise<void>] { 115 + ): [boolean, Animate] { 114 116 if (!options) options = {}; 115 117 116 118 const style = options.to || {}; ··· 128 130 }; 129 131 130 132 const animation = animate(ref.current!, options); 133 + updateAnimating(!!animation); 131 134 if (animation) { 132 - updateAnimating(true); 133 135 return animation 134 136 .then(() => { 135 137 updateAnimating(false); 136 138 }) 137 139 .catch(() => {}); 138 - } else { 139 - updateAnimating(false); 140 - return Promise.resolve(); 141 140 } 142 141 }, 143 142 [ref]