react-useanimations 2.0.4 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (362) hide show
  1. package/README.md +3 -1
  2. package/{src/bin → bin}/addAnimationFiles.sh +0 -0
  3. package/{src/bin → bin}/generateStories.sh +0 -0
  4. package/index.d.ts +19 -0
  5. package/index.js +197 -0
  6. package/{src/lib → lib}/activity/activity.json +0 -0
  7. package/lib/activity/index.d.ts +3 -0
  8. package/lib/activity/index.js +16 -0
  9. package/{src/lib → lib}/airplay/airplay.json +0 -0
  10. package/lib/airplay/index.d.ts +3 -0
  11. package/lib/airplay/index.js +16 -0
  12. package/{src/lib → lib}/alertCircle/alertCircle.json +0 -0
  13. package/lib/alertCircle/index.d.ts +3 -0
  14. package/lib/alertCircle/index.js +16 -0
  15. package/{src/lib → lib}/alertOctagon/alertOctagon.json +0 -0
  16. package/lib/alertOctagon/index.d.ts +3 -0
  17. package/lib/alertOctagon/index.js +16 -0
  18. package/{src/lib → lib}/alertTriangle/alertTriangle.json +0 -0
  19. package/lib/alertTriangle/index.d.ts +3 -0
  20. package/lib/alertTriangle/index.js +16 -0
  21. package/{src/lib → lib}/archive/archive.json +0 -0
  22. package/lib/archive/index.d.ts +3 -0
  23. package/lib/archive/index.js +16 -0
  24. package/{src/lib → lib}/arrowDown/arrowDown.json +0 -0
  25. package/lib/arrowDown/index.d.ts +3 -0
  26. package/lib/arrowDown/index.js +16 -0
  27. package/{src/lib → lib}/arrowDownCircle/arrowDownCircle.json +0 -0
  28. package/lib/arrowDownCircle/index.d.ts +3 -0
  29. package/lib/arrowDownCircle/index.js +16 -0
  30. package/{src/lib → lib}/arrowLeftCircle/arrowLeftCircle.json +0 -0
  31. package/lib/arrowLeftCircle/index.d.ts +3 -0
  32. package/lib/arrowLeftCircle/index.js +16 -0
  33. package/{src/lib → lib}/arrowRightCircle/arrowRightCircle.json +0 -0
  34. package/lib/arrowRightCircle/index.d.ts +3 -0
  35. package/lib/arrowRightCircle/index.js +16 -0
  36. package/{src/lib → lib}/arrowUp/arrowUp.json +0 -0
  37. package/lib/arrowUp/index.d.ts +3 -0
  38. package/lib/arrowUp/index.js +16 -0
  39. package/{src/lib → lib}/arrowUpCircle/arrowUpCircle.json +0 -0
  40. package/lib/arrowUpCircle/index.d.ts +3 -0
  41. package/lib/arrowUpCircle/index.js +16 -0
  42. package/lib/behance/behance.json +1 -0
  43. package/lib/behance/index.d.ts +3 -0
  44. package/lib/behance/index.js +16 -0
  45. package/{src/lib → lib}/bookmark/bookmark.json +0 -0
  46. package/lib/bookmark/index.d.ts +3 -0
  47. package/lib/bookmark/index.js +16 -0
  48. package/{src/lib → lib}/calendar/calendar.json +0 -0
  49. package/lib/calendar/index.d.ts +3 -0
  50. package/lib/calendar/index.js +16 -0
  51. package/{src/lib → lib}/checkBox/checkBox.json +0 -0
  52. package/lib/checkBox/index.d.ts +3 -0
  53. package/lib/checkBox/index.js +16 -0
  54. package/lib/checkmark/checkmark.json +1 -0
  55. package/lib/checkmark/index.d.ts +3 -0
  56. package/lib/checkmark/index.js +16 -0
  57. package/{src/lib → lib}/codepen/codepen.json +0 -0
  58. package/lib/codepen/index.d.ts +3 -0
  59. package/lib/codepen/index.js +16 -0
  60. package/{src/lib → lib}/copy/copy.json +0 -0
  61. package/lib/copy/index.d.ts +3 -0
  62. package/lib/copy/index.js +16 -0
  63. package/{src/lib → lib}/download/download.json +0 -0
  64. package/lib/download/index.d.ts +3 -0
  65. package/lib/download/index.js +16 -0
  66. package/lib/dribbble/dribbble.json +1 -0
  67. package/lib/dribbble/index.d.ts +3 -0
  68. package/lib/dribbble/index.js +16 -0
  69. package/{src/lib → lib}/edit/edit.json +0 -0
  70. package/lib/edit/index.d.ts +3 -0
  71. package/lib/edit/index.js +16 -0
  72. package/lib/error/error.json +1 -0
  73. package/lib/error/index.d.ts +3 -0
  74. package/lib/error/index.js +16 -0
  75. package/{src/lib → lib}/explore/explore.json +0 -0
  76. package/lib/explore/index.d.ts +3 -0
  77. package/lib/explore/index.js +16 -0
  78. package/{src/lib → lib}/facebook/facebook.json +0 -0
  79. package/lib/facebook/index.d.ts +3 -0
  80. package/lib/facebook/index.js +16 -0
  81. package/lib/folder/folder.json +1 -0
  82. package/lib/folder/index.d.ts +3 -0
  83. package/lib/folder/index.js +16 -0
  84. package/{src/lib → lib}/github/github.json +0 -0
  85. package/lib/github/index.d.ts +3 -0
  86. package/lib/github/index.js +16 -0
  87. package/{src/lib → lib}/heart/heart.json +0 -0
  88. package/lib/heart/index.d.ts +3 -0
  89. package/lib/heart/index.js +16 -0
  90. package/lib/help/help.json +1 -0
  91. package/lib/help/index.d.ts +3 -0
  92. package/lib/help/index.js +16 -0
  93. package/lib/home/home.json +1 -0
  94. package/lib/home/index.d.ts +3 -0
  95. package/lib/home/index.js +16 -0
  96. package/lib/infinity/index.d.ts +3 -0
  97. package/lib/infinity/index.js +16 -0
  98. package/{src/lib → lib}/infinity/infinity.json +0 -0
  99. package/lib/info/index.d.ts +3 -0
  100. package/lib/info/index.js +16 -0
  101. package/{src/lib → lib}/info/info.json +0 -0
  102. package/lib/instagram/index.d.ts +3 -0
  103. package/lib/instagram/index.js +16 -0
  104. package/{src/lib → lib}/instagram/instagram.json +0 -0
  105. package/lib/linkedin/index.d.ts +3 -0
  106. package/lib/linkedin/index.js +16 -0
  107. package/{src/lib → lib}/linkedin/linkedin.json +0 -0
  108. package/lib/loading/index.d.ts +3 -0
  109. package/lib/loading/index.js +16 -0
  110. package/{src/lib → lib}/loading/loading.json +0 -0
  111. package/lib/loading2/index.d.ts +3 -0
  112. package/lib/loading2/index.js +16 -0
  113. package/{src/lib → lib}/loading2/loading2.json +0 -0
  114. package/lib/loading3/index.d.ts +3 -0
  115. package/lib/loading3/index.js +16 -0
  116. package/{src/lib → lib}/loading3/loading3.json +0 -0
  117. package/lib/lock/index.d.ts +3 -0
  118. package/lib/lock/index.js +16 -0
  119. package/{src/lib → lib}/lock/lock.json +0 -0
  120. package/lib/mail/index.d.ts +3 -0
  121. package/lib/mail/index.js +16 -0
  122. package/{src/lib → lib}/mail/mail.json +0 -0
  123. package/lib/maximizeMinimize/index.d.ts +3 -0
  124. package/lib/maximizeMinimize/index.js +16 -0
  125. package/{src/lib → lib}/maximizeMinimize/maximizeMinimize.json +0 -0
  126. package/lib/maximizeMinimize2/index.d.ts +3 -0
  127. package/lib/maximizeMinimize2/index.js +16 -0
  128. package/{src/lib → lib}/maximizeMinimize2/maximizeMinimize2.json +0 -0
  129. package/lib/menu/index.d.ts +3 -0
  130. package/lib/menu/index.js +16 -0
  131. package/{src/lib → lib}/menu/menu.json +0 -0
  132. package/lib/menu2/index.d.ts +3 -0
  133. package/lib/menu2/index.js +16 -0
  134. package/{src/lib → lib}/menu2/menu2.json +0 -0
  135. package/lib/menu3/index.d.ts +3 -0
  136. package/lib/menu3/index.js +16 -0
  137. package/{src/lib → lib}/menu3/menu3.json +0 -0
  138. package/lib/menu4/index.d.ts +3 -0
  139. package/lib/menu4/index.js +16 -0
  140. package/{src/lib → lib}/menu4/menu4.json +0 -0
  141. package/lib/microphone/index.d.ts +3 -0
  142. package/lib/microphone/index.js +16 -0
  143. package/{src/lib → lib}/microphone/microphone.json +0 -0
  144. package/lib/microphone2/index.d.ts +3 -0
  145. package/lib/microphone2/index.js +16 -0
  146. package/{src/lib → lib}/microphone2/microphone2.json +0 -0
  147. package/lib/notification/index.d.ts +3 -0
  148. package/lib/notification/index.js +16 -0
  149. package/{src/lib → lib}/notification/notification.json +0 -0
  150. package/lib/notification2/index.d.ts +3 -0
  151. package/lib/notification2/index.js +16 -0
  152. package/{src/lib → lib}/notification2/notification2.json +0 -0
  153. package/lib/playPause/index.d.ts +3 -0
  154. package/lib/playPause/index.js +16 -0
  155. package/{src/lib → lib}/playPause/playPause.json +0 -0
  156. package/lib/playPauseCircle/index.d.ts +3 -0
  157. package/lib/playPauseCircle/index.js +16 -0
  158. package/{src/lib → lib}/playPauseCircle/playPauseCircle.json +0 -0
  159. package/lib/plusToX/index.d.ts +3 -0
  160. package/lib/plusToX/index.js +16 -0
  161. package/{src/lib → lib}/plusToX/plusToX.json +0 -0
  162. package/lib/pocket/index.d.ts +3 -0
  163. package/lib/pocket/index.js +16 -0
  164. package/{src/lib → lib}/pocket/pocket.json +0 -0
  165. package/lib/radioButton/index.d.ts +3 -0
  166. package/lib/radioButton/index.js +16 -0
  167. package/{src/lib → lib}/radioButton/radioButton.json +0 -0
  168. package/lib/scrollDown/index.d.ts +3 -0
  169. package/lib/scrollDown/index.js +16 -0
  170. package/{src/lib → lib}/scrollDown/scrollDown.json +0 -0
  171. package/lib/searchToX/index.d.ts +3 -0
  172. package/lib/searchToX/index.js +16 -0
  173. package/{src/lib → lib}/searchToX/searchToX.json +0 -0
  174. package/lib/settings/index.d.ts +3 -0
  175. package/lib/settings/index.js +16 -0
  176. package/{src/lib → lib}/settings/settings.json +0 -0
  177. package/lib/settings2/index.d.ts +3 -0
  178. package/lib/settings2/index.js +16 -0
  179. package/{src/lib → lib}/settings2/settings2.json +0 -0
  180. package/lib/share/index.d.ts +3 -0
  181. package/lib/share/index.js +16 -0
  182. package/{src/lib → lib}/share/share.json +0 -0
  183. package/lib/skipBack/index.d.ts +3 -0
  184. package/lib/skipBack/index.js +16 -0
  185. package/{src/lib → lib}/skipBack/skipBack.json +0 -0
  186. package/lib/skipForward/index.d.ts +3 -0
  187. package/lib/skipForward/index.js +16 -0
  188. package/{src/lib → lib}/skipForward/skipForward.json +0 -0
  189. package/lib/star/index.d.ts +3 -0
  190. package/lib/star/index.js +16 -0
  191. package/{src/lib → lib}/star/star.json +0 -0
  192. package/lib/thumbUp/index.d.ts +3 -0
  193. package/lib/thumbUp/index.js +16 -0
  194. package/{src/lib → lib}/thumbUp/thumbUp.json +0 -0
  195. package/lib/toggle/index.d.ts +3 -0
  196. package/lib/toggle/index.js +16 -0
  197. package/{src/lib → lib}/toggle/toggle.json +0 -0
  198. package/lib/trash/index.d.ts +3 -0
  199. package/lib/trash/index.js +16 -0
  200. package/{src/lib → lib}/trash/trash.json +0 -0
  201. package/lib/trash2/index.d.ts +3 -0
  202. package/lib/trash2/index.js +16 -0
  203. package/{src/lib → lib}/trash2/trash2.json +0 -0
  204. package/lib/twitter/index.d.ts +3 -0
  205. package/lib/twitter/index.js +16 -0
  206. package/{src/lib → lib}/twitter/twitter.json +0 -0
  207. package/lib/userMinus/index.d.ts +3 -0
  208. package/lib/userMinus/index.js +16 -0
  209. package/{src/lib → lib}/userMinus/userMinus.json +0 -0
  210. package/lib/userPlus/index.d.ts +3 -0
  211. package/lib/userPlus/index.js +16 -0
  212. package/{src/lib → lib}/userPlus/userPlus.json +0 -0
  213. package/lib/userX/index.d.ts +3 -0
  214. package/lib/userX/index.js +16 -0
  215. package/{src/lib → lib}/userX/userX.json +0 -0
  216. package/lib/video/index.d.ts +3 -0
  217. package/lib/video/index.js +16 -0
  218. package/{src/lib → lib}/video/video.json +0 -0
  219. package/lib/video2/index.d.ts +3 -0
  220. package/lib/video2/index.js +16 -0
  221. package/{src/lib → lib}/video2/video2.json +0 -0
  222. package/lib/visibility/index.d.ts +3 -0
  223. package/lib/visibility/index.js +16 -0
  224. package/{src/lib → lib}/visibility/visibility.json +0 -0
  225. package/lib/visibility2/index.d.ts +3 -0
  226. package/lib/visibility2/index.js +16 -0
  227. package/{src/lib → lib}/visibility2/visibility2.json +0 -0
  228. package/lib/volume/index.d.ts +3 -0
  229. package/lib/volume/index.js +16 -0
  230. package/{src/lib → lib}/volume/volume.json +0 -0
  231. package/lib/youtube/index.d.ts +3 -0
  232. package/lib/youtube/index.js +16 -0
  233. package/{src/lib → lib}/youtube/youtube.json +0 -0
  234. package/lib/youtube2/index.d.ts +3 -0
  235. package/lib/youtube2/index.js +16 -0
  236. package/{src/lib → lib}/youtube2/youtube2.json +0 -0
  237. package/lib/zoomIn/index.d.ts +3 -0
  238. package/lib/zoomIn/index.js +16 -0
  239. package/lib/zoomIn/zoomIn.json +1 -0
  240. package/lib/zoomOut/index.d.ts +3 -0
  241. package/lib/zoomOut/index.js +16 -0
  242. package/lib/zoomOut/zoomOut.json +1 -0
  243. package/package.json +3 -3
  244. package/stories/controlled.stories.d.ts +60 -0
  245. package/stories/controlled.stories.js +231 -0
  246. package/stories/generated.stories.d.ts +20 -0
  247. package/stories/generated.stories.js +977 -0
  248. package/stories/variants.stories.d.ts +70 -0
  249. package/stories/variants.stories.js +196 -0
  250. package/{src/typings.d.ts → typings.d.ts} +0 -0
  251. package/utils/constants.d.ts +6 -0
  252. package/utils/constants.js +1 -0
  253. package/utils/getEffect.d.ts +3 -0
  254. package/{src/utils/getEffect.ts → utils/getEffect.js} +20 -8
  255. package/utils/getEvents.d.ts +12 -0
  256. package/utils/getEvents.js +96 -0
  257. package/{src/utils/index.ts → utils/index.d.ts} +0 -0
  258. package/utils/index.js +23 -0
  259. package/.babelrc +0 -4
  260. package/.editorconfig +0 -15
  261. package/.eslintignore +0 -2
  262. package/.eslintrc.json +0 -31
  263. package/.gitattributes +0 -1
  264. package/.prettierrc +0 -10
  265. package/.storybook/main.js +0 -15
  266. package/.vscode/settings.json +0 -5
  267. package/LICENSE +0 -30
  268. package/README_v1 +0 -46
  269. package/docs/favicon.ico +0 -0
  270. package/docs/iframe.html +0 -74
  271. package/docs/index.html +0 -19
  272. package/docs/main.3130f3b2fabe967f88b6.bundle.js +0 -2
  273. package/docs/main.3130f3b2fabe967f88b6.bundle.js.map +0 -1
  274. package/docs/main.45196b906e96983a4bff.bundle.js +0 -1
  275. package/docs/runtime~main.286b69a873d49f2f199c.bundle.js +0 -1
  276. package/docs/runtime~main.3130f3b2fabe967f88b6.bundle.js +0 -2
  277. package/docs/runtime~main.3130f3b2fabe967f88b6.bundle.js.map +0 -1
  278. package/docs/sb_dll/storybook_ui-manifest.json +0 -1
  279. package/docs/sb_dll/storybook_ui_dll.LICENCE +0 -113
  280. package/docs/sb_dll/storybook_ui_dll.js +0 -2
  281. package/docs/vendors~main.3130f3b2fabe967f88b6.bundle.js +0 -3
  282. package/docs/vendors~main.3130f3b2fabe967f88b6.bundle.js.LICENSE.txt +0 -120
  283. package/docs/vendors~main.3130f3b2fabe967f88b6.bundle.js.map +0 -1
  284. package/docs/vendors~main.f556fb49f847b250db46.bundle.js +0 -128
  285. package/src/index.tsx +0 -149
  286. package/src/lib/activity/index.ts +0 -4
  287. package/src/lib/airplay/index.ts +0 -4
  288. package/src/lib/alertCircle/index.ts +0 -4
  289. package/src/lib/alertOctagon/index.ts +0 -4
  290. package/src/lib/alertTriangle/index.ts +0 -4
  291. package/src/lib/archive/index.ts +0 -4
  292. package/src/lib/arrowDown/index.ts +0 -4
  293. package/src/lib/arrowDownCircle/index.ts +0 -4
  294. package/src/lib/arrowLeftCircle/index.ts +0 -4
  295. package/src/lib/arrowRightCircle/index.ts +0 -4
  296. package/src/lib/arrowUp/index.ts +0 -4
  297. package/src/lib/arrowUpCircle/index.ts +0 -4
  298. package/src/lib/bookmark/index.ts +0 -4
  299. package/src/lib/calendar/index.ts +0 -4
  300. package/src/lib/checkBox/index.ts +0 -4
  301. package/src/lib/codepen/index.ts +0 -4
  302. package/src/lib/copy/index.ts +0 -4
  303. package/src/lib/download/index.ts +0 -4
  304. package/src/lib/edit/index.ts +0 -4
  305. package/src/lib/explore/index.ts +0 -4
  306. package/src/lib/facebook/index.ts +0 -4
  307. package/src/lib/github/index.ts +0 -4
  308. package/src/lib/heart/index.ts +0 -4
  309. package/src/lib/infinity/index.ts +0 -4
  310. package/src/lib/info/index.ts +0 -4
  311. package/src/lib/instagram/index.ts +0 -4
  312. package/src/lib/linkedin/index.ts +0 -4
  313. package/src/lib/loading/index.ts +0 -4
  314. package/src/lib/loading2/index.ts +0 -4
  315. package/src/lib/loading3/index.ts +0 -4
  316. package/src/lib/lock/index.ts +0 -4
  317. package/src/lib/mail/index.ts +0 -4
  318. package/src/lib/maximizeMinimize/index.ts +0 -4
  319. package/src/lib/maximizeMinimize2/index.ts +0 -4
  320. package/src/lib/menu/index.ts +0 -4
  321. package/src/lib/menu2/index.ts +0 -4
  322. package/src/lib/menu3/index.ts +0 -4
  323. package/src/lib/menu4/index.ts +0 -4
  324. package/src/lib/microphone/index.ts +0 -4
  325. package/src/lib/microphone2/index.ts +0 -4
  326. package/src/lib/notification/index.ts +0 -4
  327. package/src/lib/notification2/index.ts +0 -4
  328. package/src/lib/playPause/index.ts +0 -4
  329. package/src/lib/playPauseCircle/index.ts +0 -4
  330. package/src/lib/plusToX/index.ts +0 -4
  331. package/src/lib/pocket/index.ts +0 -4
  332. package/src/lib/radioButton/index.ts +0 -4
  333. package/src/lib/scrollDown/index.ts +0 -4
  334. package/src/lib/searchToX/index.ts +0 -4
  335. package/src/lib/settings/index.ts +0 -4
  336. package/src/lib/settings2/index.ts +0 -4
  337. package/src/lib/share/index.ts +0 -4
  338. package/src/lib/skipBack/index.ts +0 -4
  339. package/src/lib/skipForward/index.ts +0 -4
  340. package/src/lib/star/index.ts +0 -4
  341. package/src/lib/thumbUp/index.ts +0 -4
  342. package/src/lib/toggle/index.ts +0 -4
  343. package/src/lib/trash/index.ts +0 -4
  344. package/src/lib/trash2/index.ts +0 -4
  345. package/src/lib/twitter/index.ts +0 -4
  346. package/src/lib/userMinus/index.ts +0 -4
  347. package/src/lib/userPlus/index.ts +0 -4
  348. package/src/lib/userX/index.ts +0 -4
  349. package/src/lib/video/index.ts +0 -4
  350. package/src/lib/video2/index.ts +0 -4
  351. package/src/lib/visibility/index.ts +0 -4
  352. package/src/lib/visibility2/index.ts +0 -4
  353. package/src/lib/volume/index.ts +0 -4
  354. package/src/lib/youtube/index.ts +0 -4
  355. package/src/lib/youtube2/index.ts +0 -4
  356. package/src/stories/controlled.stories.tsx +0 -30
  357. package/src/stories/generated.stories.tsx +0 -361
  358. package/src/stories/variants.stories.tsx +0 -180
  359. package/src/utils/constants.ts +0 -84
  360. package/src/utils/getEvents.ts +0 -81
  361. package/tsconfig.json +0 -67
  362. package/useanimations-preview.gif +0 -0
package/src/index.tsx DELETED
@@ -1,149 +0,0 @@
1
- import React, { useState, useEffect, useRef, ReactElement } from 'react';
2
- // UNFORTUNATELY WHEN LIGHT VERSION IS USED, SOME ANIMATIONS ARE NOT WORKING AS EXPECTED
3
- // import lottie from 'lottie-web/build/player/lottie_light';
4
- import lottie from 'lottie-web';
5
- import type { AnimationItem, AnimationConfigWithData, AnimationConfig } from 'lottie-web';
6
-
7
- import { getEffect, getEvents } from './utils';
8
- import type { Animation, AnimationEffect } from './utils';
9
-
10
- const getRandomId = (key: Animation['animationKey']) =>
11
- `${key}_i${Math.floor(Math.random() * 10000 + 1)}`;
12
-
13
- type Props = {
14
- animation: Animation;
15
- reverse?: boolean;
16
- strokeColor?: string;
17
- pathCss?: string;
18
- options?: Partial<AnimationConfig>;
19
- size?: number;
20
- loop?: AnimationConfig['loop'];
21
- autoplay?: AnimationConfig['autoplay'];
22
- wrapperStyle?: React.CSSProperties;
23
- render?: (eventProps: any, animationProps: any) => ReactElement;
24
- } & React.HTMLProps<HTMLDivElement>;
25
-
26
- const UseAnimations: React.FC<Props> = ({
27
- animation: { animationData, animationKey },
28
- reverse = false,
29
- size = 24,
30
- strokeColor,
31
- pathCss,
32
- loop,
33
- autoplay,
34
- wrapperStyle,
35
- options,
36
- onClick,
37
- render,
38
- ...other
39
- }) => {
40
- const [animation, setAnimation] = useState<AnimationItem>();
41
- const ref = useRef<HTMLDivElement>(null);
42
-
43
- useEffect(() => {
44
- const animEffect: AnimationEffect = getEffect(animationKey);
45
- const animationId = getRandomId(animationKey);
46
-
47
- if (strokeColor || pathCss) {
48
- try {
49
- const css = `#${animationId} path { stroke: ${strokeColor || 'inherit'}; ${pathCss || ''}}`;
50
- let sheetEl: any = document.getElementById('useAnimationsSheet');
51
-
52
- // STYLESHEET HASN'T BEEN CREATED YET
53
- if (!sheetEl) {
54
- sheetEl = document.createElement('style');
55
- sheetEl.setAttribute('id', 'useAnimationsSheet');
56
- sheetEl.appendChild(document.createTextNode(''));
57
- document.head.appendChild(sheetEl);
58
- }
59
-
60
- const sheet = sheetEl ? sheetEl.sheet || sheetEl.styleSheet : null;
61
- sheet.insertRule(css);
62
- } catch (err) {
63
- // eslint-disable-next-line
64
- console.warn(
65
- `There's been a problem with deleting a CSSRule, please report that issue in https://github.com/useAnimations/react-useanimations`,
66
- err
67
- );
68
- }
69
- }
70
-
71
- const defaultOptions: AnimationConfigWithData = {
72
- container: ref.current as Element,
73
- renderer: 'svg',
74
- animationData,
75
- loop: loop || animEffect === 'LOOP_PLAY',
76
- autoplay: autoplay || animEffect === 'LOOP_PLAY',
77
- rendererSettings: {
78
- // LOADS DOM ELEMENTS WHEN NEEDED. MIGHT SPEED UP INITIALIZATION FOR LARGE NUMBER OF ELEMENTS.
79
- progressiveLoad: true,
80
- // lottie-web missing id type
81
- // @ts-ignore-next-line
82
- id: animationId,
83
- },
84
- ...options,
85
- };
86
-
87
- setAnimation(lottie.loadAnimation(defaultOptions));
88
-
89
- return () => {
90
- animation?.destroy();
91
- setAnimation(undefined);
92
- // DELETE CSS RULE
93
- try {
94
- const sheetEl: any = document.getElementById('useAnimationsSheet');
95
- const sheet = sheetEl ? sheetEl.sheet || sheetEl.styleSheet : null;
96
-
97
- if (sheet) {
98
- const animationRuleIndex = Array.from(sheet.cssRules).findIndex(
99
- (rule: any) => rule.selectorText === `#${animationId} path`
100
- );
101
-
102
- if (animationRuleIndex !== -1) {
103
- sheet.deleteRule(animationRuleIndex);
104
- }
105
- }
106
- } catch (err) {
107
- // eslint-disable-next-line
108
- console.warn(
109
- `There's been a problem with deleting a CSSRule, please report that issue in https://github.com/useAnimations/react-useanimations`,
110
- err
111
- );
112
- }
113
- };
114
- }, []);
115
-
116
- const defaultStyles = {
117
- overflow: 'hidden',
118
- outline: 'none',
119
- width: `${size}px`,
120
- height: `${size}px`,
121
- ...wrapperStyle,
122
- };
123
-
124
- const events = animation
125
- ? getEvents({
126
- animation,
127
- reverse,
128
- animEffect: getEffect(animationKey),
129
- })
130
- : undefined;
131
-
132
- const eventProps = {
133
- ...events,
134
- onClick: (e: React.MouseEvent<HTMLDivElement>) => {
135
- if (onClick) onClick(e);
136
- if (events && 'onClick' in events) events.onClick();
137
- },
138
- };
139
-
140
- const animationProps = {
141
- ref,
142
- ...other,
143
- style: defaultStyles,
144
- };
145
-
146
- return render ? render(eventProps, animationProps) : <div {...eventProps} {...animationProps} />;
147
- };
148
-
149
- export default UseAnimations;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import activity from './activity.json';
3
-
4
- export default { animationData: activity, animationKey: 'activity' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import airplay from './airplay.json';
3
-
4
- export default { animationData: airplay, animationKey: 'airplay' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import alertCircle from './alertCircle.json';
3
-
4
- export default { animationData: alertCircle, animationKey: 'alertCircle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import alertOctagon from './alertOctagon.json';
3
-
4
- export default { animationData: alertOctagon, animationKey: 'alertOctagon' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import alertTriangle from './alertTriangle.json';
3
-
4
- export default { animationData: alertTriangle, animationKey: 'alertTriangle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import archive from './archive.json';
3
-
4
- export default { animationData: archive, animationKey: 'archive' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import arrowDown from './arrowDown.json';
3
-
4
- export default { animationData: arrowDown, animationKey: 'arrowDown' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import arrowDownCircle from './arrowDownCircle.json';
3
-
4
- export default { animationData: arrowDownCircle, animationKey: 'arrowDownCircle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import arrowLeftCircle from './arrowLeftCircle.json';
3
-
4
- export default { animationData: arrowLeftCircle, animationKey: 'arrowLeftCircle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import arrowRightCircle from './arrowRightCircle.json';
3
-
4
- export default { animationData: arrowRightCircle, animationKey: 'arrowRightCircle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import arrowUp from './arrowUp.json';
3
-
4
- export default { animationData: arrowUp, animationKey: 'arrowUp' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import arrowUpCircle from './arrowUpCircle.json';
3
-
4
- export default { animationData: arrowUpCircle, animationKey: 'arrowUpCircle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import bookmark from './bookmark.json';
3
-
4
- export default { animationData: bookmark, animationKey: 'bookmark' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import calendar from './calendar.json';
3
-
4
- export default { animationData: calendar, animationKey: 'calendar' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import checkBox from './checkBox.json';
3
-
4
- export default { animationData: checkBox, animationKey: 'checkBox' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import codepen from './codepen.json';
3
-
4
- export default { animationData: codepen, animationKey: 'codepen' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import copy from './copy.json';
3
-
4
- export default { animationData: copy, animationKey: 'copy' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import download from './download.json';
3
-
4
- export default { animationData: download, animationKey: 'download' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import edit from './edit.json';
3
-
4
- export default { animationData: edit, animationKey: 'edit' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import explore from './explore.json';
3
-
4
- export default { animationData: explore, animationKey: 'explore' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import facebook from './facebook.json';
3
-
4
- export default { animationData: facebook, animationKey: 'facebook' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import github from './github.json';
3
-
4
- export default { animationData: github, animationKey: 'github' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import heart from './heart.json';
3
-
4
- export default { animationData: heart, animationKey: 'heart' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import infinity from './infinity.json';
3
-
4
- export default { animationData: infinity, animationKey: 'infinity' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import info from './info.json';
3
-
4
- export default { animationData: info, animationKey: 'info' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import instagram from './instagram.json';
3
-
4
- export default { animationData: instagram, animationKey: 'instagram' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import linkedin from './linkedin.json';
3
-
4
- export default { animationData: linkedin, animationKey: 'linkedin' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import loading from './loading.json';
3
-
4
- export default { animationData: loading, animationKey: 'loading' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import loading2 from './loading2.json';
3
-
4
- export default { animationData: loading2, animationKey: 'loading2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import loading3 from './loading3.json';
3
-
4
- export default { animationData: loading3, animationKey: 'loading3' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import lock from './lock.json';
3
-
4
- export default { animationData: lock, animationKey: 'lock' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import mail from './mail.json';
3
-
4
- export default { animationData: mail, animationKey: 'mail' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import maximizeMinimize from './maximizeMinimize.json';
3
-
4
- export default { animationData: maximizeMinimize, animationKey: 'maximizeMinimize' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import maximizeMinimize2 from './maximizeMinimize2.json';
3
-
4
- export default { animationData: maximizeMinimize2, animationKey: 'maximizeMinimize2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import menu from './menu.json';
3
-
4
- export default { animationData: menu, animationKey: 'menu' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import menu2 from './menu2.json';
3
-
4
- export default { animationData: menu2, animationKey: 'menu2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import menu3 from './menu3.json';
3
-
4
- export default { animationData: menu3, animationKey: 'menu3' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import menu4 from './menu4.json';
3
-
4
- export default { animationData: menu4, animationKey: 'menu4' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import microphone from './microphone.json';
3
-
4
- export default { animationData: microphone, animationKey: 'microphone' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import microphone2 from './microphone2.json';
3
-
4
- export default { animationData: microphone2, animationKey: 'microphone2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import notification from './notification.json';
3
-
4
- export default { animationData: notification, animationKey: 'notification' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import notification2 from './notification2.json';
3
-
4
- export default { animationData: notification2, animationKey: 'notification2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import playPause from './playPause.json';
3
-
4
- export default { animationData: playPause, animationKey: 'playPause' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import playPauseCircle from './playPauseCircle.json';
3
-
4
- export default { animationData: playPauseCircle, animationKey: 'playPauseCircle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import plusToX from './plusToX.json';
3
-
4
- export default { animationData: plusToX, animationKey: 'plusToX' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import pocket from './pocket.json';
3
-
4
- export default { animationData: pocket, animationKey: 'pocket' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import radioButton from './radioButton.json';
3
-
4
- export default { animationData: radioButton, animationKey: 'radioButton' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import scrollDown from './scrollDown.json';
3
-
4
- export default { animationData: scrollDown, animationKey: 'scrollDown' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import searchToX from './searchToX.json';
3
-
4
- export default { animationData: searchToX, animationKey: 'searchToX' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import settings from './settings.json';
3
-
4
- export default { animationData: settings, animationKey: 'settings' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import settings2 from './settings2.json';
3
-
4
- export default { animationData: settings2, animationKey: 'settings2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import share from './share.json';
3
-
4
- export default { animationData: share, animationKey: 'share' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import skipBack from './skipBack.json';
3
-
4
- export default { animationData: skipBack, animationKey: 'skipBack' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import skipForward from './skipForward.json';
3
-
4
- export default { animationData: skipForward, animationKey: 'skipForward' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import star from './star.json';
3
-
4
- export default { animationData: star, animationKey: 'star' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import thumbUp from './thumbUp.json';
3
-
4
- export default { animationData: thumbUp, animationKey: 'thumbUp' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import toggle from './toggle.json';
3
-
4
- export default { animationData: toggle, animationKey: 'toggle' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import trash from './trash.json';
3
-
4
- export default { animationData: trash, animationKey: 'trash' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import trash2 from './trash2.json';
3
-
4
- export default { animationData: trash2, animationKey: 'trash2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import twitter from './twitter.json';
3
-
4
- export default { animationData: twitter, animationKey: 'twitter' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import userMinus from './userMinus.json';
3
-
4
- export default { animationData: userMinus, animationKey: 'userMinus' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import userPlus from './userPlus.json';
3
-
4
- export default { animationData: userPlus, animationKey: 'userPlus' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import userX from './userX.json';
3
-
4
- export default { animationData: userX, animationKey: 'userX' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import video from './video.json';
3
-
4
- export default { animationData: video, animationKey: 'video' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import video2 from './video2.json';
3
-
4
- export default { animationData: video2, animationKey: 'video2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import visibility from './visibility.json';
3
-
4
- export default { animationData: visibility, animationKey: 'visibility' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import visibility2 from './visibility2.json';
3
-
4
- export default { animationData: visibility2, animationKey: 'visibility2' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import volume from './volume.json';
3
-
4
- export default { animationData: volume, animationKey: 'volume' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import youtube from './youtube.json';
3
-
4
- export default { animationData: youtube, animationKey: 'youtube' } as Animation;
@@ -1,4 +0,0 @@
1
- import type { Animation } from '../../utils/constants';
2
- import youtube2 from './youtube2.json';
3
-
4
- export default { animationData: youtube2, animationKey: 'youtube2' } as Animation;
@@ -1,30 +0,0 @@
1
- import React, { useState } from 'react';
2
- import radioButton from '../lib/radioButton';
3
- import UseAnimation from '..';
4
-
5
- // ANIMATIONS WITH CLICK PLAY & BACKWARDS WILL HAVE REVERSE FUNCITONALITY FOR STATE MNG
6
- export default {
7
- title: 'Controlled State',
8
- component: UseAnimation,
9
- };
10
-
11
- export const RadioButton = () => {
12
- const [checked, setChecked] = useState(true);
13
-
14
- return (
15
- <div style={{ display: 'flex', flexWrap: 'wrap' }}>
16
- <div style={{ padding: '20px' }}>
17
- <span>radioButton</span>
18
- <UseAnimation
19
- reverse={checked}
20
- onClick={() => {
21
- setChecked(!checked);
22
- }}
23
- size={40}
24
- wrapperStyle={{ marginTop: '5px' }}
25
- animation={radioButton}
26
- />
27
- </div>
28
- </div>
29
- );
30
- };